<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: word-sdk</title>
    <description>The latest articles on DEV Community by word-sdk (@wordsdk).</description>
    <link>https://dev.to/wordsdk</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3642991%2F02605b68-79e7-408e-a24b-42e6e13f0667.png</url>
      <title>DEV Community: word-sdk</title>
      <link>https://dev.to/wordsdk</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/wordsdk"/>
    <language>en</language>
    <item>
      <title>Enterprise Interop Made Easy: WASM Compiled Libraries for Java Developers</title>
      <dc:creator>word-sdk</dc:creator>
      <pubDate>Wed, 03 Dec 2025 10:56:27 +0000</pubDate>
      <link>https://dev.to/wordsdk/enterprise-interop-made-easy-wasm-compiled-libraries-for-java-developers-19k9</link>
      <guid>https://dev.to/wordsdk/enterprise-interop-made-easy-wasm-compiled-libraries-for-java-developers-19k9</guid>
      <description>&lt;p&gt;WebAssembly (WASM) is rapidly evolving into the &lt;strong&gt;“universal virtual machine”&lt;/strong&gt;. Originally designed to let browsers run non‑JavaScript code, WASM has grown beyond its initial scope. Today, major toolchains such as &lt;strong&gt;C/C++&lt;/strong&gt;, &lt;strong&gt;Rust&lt;/strong&gt;, &lt;strong&gt;Go&lt;/strong&gt;, &lt;strong&gt;Zig&lt;/strong&gt;, and even higher‑level languages like &lt;strong&gt;Python&lt;/strong&gt; and &lt;strong&gt;C#&lt;/strong&gt; can compile to WASM, making it a powerful cross‑platform runtime.&lt;/p&gt;




&lt;h2&gt;
  
  
  WASM vs JVM: Two Stack Machines
&lt;/h2&gt;

&lt;p&gt;Both the &lt;strong&gt;WASM Virtual Machine&lt;/strong&gt; and the &lt;strong&gt;Java Virtual Machine (JVM)&lt;/strong&gt; are &lt;em&gt;stack‑based machines&lt;/em&gt;. This architectural similarity means that compiling from WASM bytecode to JVM bytecode is not only possible but practical. Projects like &lt;a href="https://github.com/dylibso/chicory" rel="noopener noreferrer"&gt;Chicory&lt;/a&gt; demonstrate this by translating WASM modules into native JVM classes.&lt;/p&gt;

&lt;p&gt;This approach solves a long‑standing problem:  &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;How do we reuse existing C/C++ libraries in modern toolchains without rewriting everything?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Traditionally, developers faced two choices:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The Java Approach&lt;/strong&gt;: Rewrite everything in Java for portability and security.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Python Approach&lt;/strong&gt;: Wrap native libraries via shared libraries/DLLs for quick integration.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each has trade‑offs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Java: Interoperability and sandboxed execution (no risky system calls).
&lt;/li&gt;
&lt;li&gt;Python: Fast integration with wrappers.
&lt;/li&gt;
&lt;li&gt;Python downside: Requires platform‑specific DLLs/shared libraries.
&lt;/li&gt;
&lt;li&gt;Java downside: Costly rewrites of large codebases.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  WASM as the Bridge
&lt;/h2&gt;

&lt;p&gt;With WASM, we no longer need to choose between rewriting or wrapping. Instead:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Compile existing C/C++ code to WASM.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Translate WASM into JVM classes using Chicory.&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Expose the result as a native Java library.&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This yields a &lt;strong&gt;pure JVM artifact&lt;/strong&gt; — no external DLLs, no native dependencies — while still leveraging proven C/C++ libraries.&lt;/p&gt;




&lt;h2&gt;
  
  
  Proof of Concept: DOCX to PDF in Java
&lt;/h2&gt;

&lt;p&gt;As a demonstration, we compiled a non‑trivial C/C++ library capable of rendering Microsoft Word &lt;code&gt;.docx&lt;/code&gt; files to PDF. Using Chicory, we produced a native Java library published via Maven: &lt;a href="https://github.com/word-sdk/wordsdk-java-helloworld" rel="noopener noreferrer"&gt;WordSDK Java HelloWorld&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here’s how it integrates with e.g. &lt;a href="https://www.docx4java.org/trac/docx4j" rel="noopener noreferrer"&gt;Docx4J&lt;/a&gt; to produce a PDF:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;WordSDK&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;Worker&lt;/span&gt; &lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nc"&gt;WordSDK&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;createWorker&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;        
&lt;span class="c1"&gt;// Create an import stream for feeding into WordSDK&lt;/span&gt;
&lt;span class="nc"&gt;OutputStream&lt;/span&gt; &lt;span class="n"&gt;importStream&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;createImportStream&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;  
&lt;span class="c1"&gt;// feed the DOCX4J document into WordSDK&lt;/span&gt;
&lt;span class="nc"&gt;Docx4J&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;save&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;wordMLPackage&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;importStream&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Docx4J&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;FLAG_NONE&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt; 
&lt;span class="c1"&gt;// generate an in-memory PDF for further processing...    &lt;/span&gt;
&lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="kt"&gt;byte&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;pdf&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;exportPDF&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result: a &lt;strong&gt;native JVM library&lt;/strong&gt; that consumes WASM‑compiled C/C++ code, seamlessly integrated into Java enterprise workflows. Go to &lt;a href="https://github.com/word-sdk/wordsdk-java-helloworld" rel="noopener noreferrer"&gt;WordSDK Java HelloWorld&lt;/a&gt; to give it a try!&lt;/p&gt;




&lt;h2&gt;
  
  
  Performance
&lt;/h2&gt;

&lt;p&gt;One of the most common questions when introducing a new runtime layer is: &lt;em&gt;“But how fast is it?”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The good news: performance is excellent. Running WASM modules inside the JVM via &lt;a href="https://github.com/dylibso/chicory" rel="noopener noreferrer"&gt;Chicory&lt;/a&gt; is comparable to executing WASM in environments like Node.js. As with any virtual machine, there is a small overhead compared to native execution, but this is the same trade‑off developers already accept when running code in the JVM or other managed runtimes.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why This Matters
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Enterprise relevance&lt;/strong&gt;: Many systems still rely heavily on Java.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security&lt;/strong&gt;: No native DLLs or system calls — everything runs inside the JVM sandbox.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Portability&lt;/strong&gt;: WASM makes libraries cross‑platform by design.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Future‑proofing&lt;/strong&gt;: WASM is becoming the universal compilation target, much like the JVM did for Java.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Special Thanks
&lt;/h2&gt;

&lt;p&gt;Huge credit to the &lt;a href="https://github.com/dylibso/chicory" rel="noopener noreferrer"&gt;Chicory project&lt;/a&gt;. Its ability to compile non‑trivial WASM modules into JVM classes is a game‑changer for developers bridging ecosystems.&lt;/p&gt;




&lt;p&gt;We are curious to hear how this approach could fit into your enterprise workflows — and if you’ve experimented with this approach yourself, we’d love to learn from your experiences too.&lt;/p&gt;

</description>
      <category>webassembly</category>
      <category>java</category>
      <category>pdf</category>
      <category>c</category>
    </item>
  </channel>
</rss>
