{"id":3611,"date":"2022-12-23T01:01:00","date_gmt":"2022-12-23T01:01:00","guid":{"rendered":"https:\/\/www.javaadvent.com\/?p=3611"},"modified":"2023-01-11T16:19:04","modified_gmt":"2023-01-11T16:19:04","slug":"webassembly-for-the-java-geek","status":"publish","type":"post","link":"https:\/\/www.javaadvent.com\/2022\/12\/webassembly-for-the-java-geek.html","title":{"rendered":"WebAssembly for the Java Geek"},"content":{"rendered":"<p>When many Java developers hear the word WebAssembly, the first thing they think is \u201cbrowser technology\u201d. The second thing: \u201cit\u2019s the JVM all over again\u201d. After all, for a Java developer, in-browser apps are <strong>prehistory<\/strong>.<\/p>\n<div style=\"float: left;margin-right: 1em\"><img data-recalc-dims=\"1\" decoding=\"async\" style=\"width: 200px\" src=\"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2022\/12\/fic75wu.png?w=600\" \/><\/div>\n<p>In the last few weeks, there have been quite a few announcements around WebAssembly, such as the <a href=\"https:\/\/www.docker.com\/blog\/docker-wasm-technical-preview\/\">Docker+Wasm Technical Preview<\/a>. As a Java geek myself, I think we should not dismiss this technology as just a fad.<\/p>\n<p>Indeed, WebAssembly <strong><em>is<\/em><\/strong> \u201ca bytecode for the Web\u201d (I mean, that\u2019s the name after all), but the similarities between Java and <strong>Wasm<\/strong> (lower-cased: it\u2019s a contraction, not an acronym!) really end here.<\/p>\n<p>If you want to know more about how we came to define the WebAssembly standard, <a href=\"https:\/\/evacchi.github.io\/wasm\/compilers\/history\/2022\/11\/23\/a-history-of-webassembly.html\">you can learn more about its history on my own blog<\/a>. In the following, I will try to argue that <strong>there is more to WebAssembly than \u201cjust the web\u201d.<\/strong><\/p>\n<p>First of all, a WebAssembly runtime is only shallowly similar to a JVM. For instance, WebAssembly was always meant to be <em>a proper compilation target<\/em> for different programming languages, while the JVM was not, at least, not originally.<\/p>\n<h2 id=\"myth-1-the-jvm-is-a-polyglot-compilation-target\">Myth #1: The JVM Is A Polyglot Compilation Target<\/h2>\n<p>Of course, everyone knows the JVM is one of richest, interoperable language ecosystems there is. We don\u2019t have just Java, we also have Scala, Jython, JRuby, Clojure, Groovy, Kotlin and many many others.<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" style=\"float: right;width: 100px;margin-left: .5em\" src=\"https:\/\/i0.wp.com\/i.imgur.com\/LTOaClW.png?w=600&#038;ssl=1\" \/><\/p>\n<p>However, the sad, sad reality is that <strong>Java bytecode was never really meant to be a general-purpose compilation target<\/strong>. In fact, you can even find <a href=\"https:\/\/dl.acm.org\/doi\/10.1145\/1711506.1711508\">literary references<\/a> that spell that out clearly; in <a href=\"https:\/\/dl.acm.org\/doi\/10.1145\/1711506.1711508\">\u201cBytecodes meet combinators: <code>invokedynamic<\/code> \u00a0on the JVM\u201d, John Rose<\/a> writes (bold mine):<\/p>\n<blockquote><p>The Java Virtual Machine (JVM) has been widely adopted in part because of its classfile format, which is portable, compact, modular, verifiable, and reasonably easy to work with. <strong>However, it was designed for just one language\u2014Java\u2014<\/strong> and so when it is used to express programs in other source languages, there are often \u201cpain points\u201d which retard both development and execution.<\/p><\/blockquote>\n<p>The paper describes how and why the <code>invokedynamic<\/code> opcode was introduced in the JVM; in fact, it was specifically introduced to support dynamic languages targeting the JVM as a runtime. At the time, those were many: JRuby, Jython, Groovy, etc\u2026 This opcode was not added <em>because<\/em> the JVM was <em>supposed<\/em> to support such languages; but because people were doing it anyway: so, it was better just to acknowledge it!<\/p>\n<p>In other words, the JVM, as it was at the time, was <em>not<\/em> an adequate compilation target for dynamic languages. We may even argue that the JVM became a compiler target not because it was the <strong>best<\/strong> compilation target, but because people wanted to interoperate with it because of adoption and support \u2026just like JavaScript!<\/p>\n<h2 id=\"graalvm-one-vm-to-rule-them-all\">GraalVM: One VM to Rule Them All<\/h2>\n<p>The <a href=\"https:\/\/www.graalvm.org\/\">GraalVM<\/a> project has recently gone mainstream. This project includes a Just-in-Time compiler targeting regular Java bytecode, an API to build efficient language interpreters, and, recently, a native image compiler.<\/p>\n<p>One of the original goals for GraalVM was to be <a href=\"https:\/\/dl.acm.org\/doi\/10.1145\/2509578.2509581\">\u201cOne VM to rule them all\u201d<\/a>, i.e. to be a <em>polyglot runtime<\/em>.<\/p>\n<p>But Truffle does not define a polyglot <em>compilation target<\/em>. Instead, the Truffle API allows you to <em>build<\/em> an efficient, JITting <strong>interpreter<\/strong> for <em>dynamic programming languages<\/em> using a very high-level representation (an AST-based interpreter, if you are interested).<\/p>\n<div style=\"font-size: 80%\">\n<p style=\"padding-left: 40px\"><strong>Note for the nitpicker. <\/strong>Now, once you enter the programming-language-rabbit-hole everything gets kind of \u201cmeta\u201d. Indeed, with Truffle you can write a JITting interpreter for some other \u201cproper\u201d bytecode format.<\/p>\n<p style=\"padding-left: 40px\">In fact, there is a Truffle-based interpreter for LLVM (Sulong); and, sure, LLVM bitcode is <em>meant<\/em> to be a multi-platform\/multi-target compilation target. So, by the transitive property, you may argue that GraalVM\/Truffle do support a multi-platform compilation target.<\/p>\n<p style=\"padding-left: 40px\">This is technically correct (<a href=\"https:\/\/www.youtube.com\/watch?v=hou0lU8WMgo\">which is the <em>best<\/em> kind of correct<\/a>), but there are many considerations to be made, and there is not enough space here to discuss them all. In short, LLVM bitcode is meant to be a compilation target, but it was not necessarily meant to be a cross-platform <em>runtime language<\/em> (e.g., there are slight variations in the instructions you may have to use, depending on the CPU\/OS you want to target). Moreover, as opposed to WebAssembly, which is a multi-vendor standard, GraalVM and Truffle are, to this day, open source, community-driven, but single-implementation efforts (<a href=\"https:\/\/www.graalvm.org\/2022\/openjdk-announcement\/\">work has recently started to bring it to the OpenJDK and possibly to the Java Language Specification<\/a>).<\/p>\n<p style=\"padding-left: 40px\">Ultimately, WebAssembly is also another language that GraalVM\/Truffle is able to support, so if you want to use GraalVM, you might even target Wasm!<\/p>\n<\/div>\n<h2 id=\"myth-2-its-just-another-stack-based-language-vm\">Myth #2: It\u2019s Just Another Stack-based Language VM<\/h2>\n<p>WebAssembly is defined as a virtual instruction set architecture (ISA) for a <a href=\"https:\/\/github.com\/WebAssembly\/design\/blob\/main\/Rationale.md\"><em>structured<\/em> stack-based virtual machine<\/a>.<\/p>\n<p>The word <em>structured<\/em> here is key, because it is a very significant departure from the way, say, the JVM works. In practice, in a structured stack machine most computations use a stack of values, but control flow is expressed in structured constructs such as blocks, ifs, and loops. Moreover, in the WebAssembly language, some instructions can be represented both as \u201csimple\u201d and as \u201cnested\u201d.<\/p>\n<p>Let\u2019s see an example. In the stack-based Wasm machine the expression:<\/p>\n<pre>( x + 2 ) * 3<\/pre>\n<div id=\"cb2\" class=\"sourceCode\">\n<pre class=\"sourceCode asm\"> int exp(int);\n    Code:\n       0: iload_1\n       1: iconst_2\n       2: iadd\n       3: iconst_3\n       4: imul\n       5: ireturn<\/pre>\n<\/div>\n<p>Could be translated in the following sequence of instructions:<\/p>\n<div id=\"cb3\" class=\"sourceCode\">\n<pre class=\"sourceCode scheme\">(local.get $x) \n(i32.const 2) \ni32.add \n(i32.const 3) \ni32.mul<\/pre>\n<\/div>\n<ul>\n<li><code>local.get<\/code> puts the value of the local variable <code>$x<\/code> on the stack<\/li>\n<li>then the <code>i32.const<\/code> pushes the 32-bit integer (<code>i32<\/code>) constant <code>2<\/code> on the stack<\/li>\n<li><code>i32.add<\/code> pops the two values from the stack, and push the result <code>$x+2<\/code> on the stack<\/li>\n<li>we then push the integer constant <code>3<\/code><\/li>\n<li><code>i32.mul<\/code> pops the two integer values and pushes the <code>i32<\/code> result of the multiplication (<code>($x+2)*3<\/code>)<\/li>\n<\/ul>\n<p>You may have noticed how instructions that take at least one argument are parenthesized. The one we just saw is the \u201clinearized\u201d version of WebAssembly. It is the one that is straightforwardly translated into its binary representation in a <code>.wasm<\/code> file. There is however another, semantically equivalent \u201cnested\u201d representation:<\/p>\n<div id=\"cb4\" class=\"sourceCode\">\n<pre class=\"sourceCode scheme\">(i32.mul \n  (i32.add \n    (local.get $x) \n      (i32.const 2)) \n    (i32.const 3))<\/pre>\n<\/div>\n<p>The nested representation is particularly interesting because it shows a peculiar difference with other types of bytecodes (such the JVM\u2019s), i.e. operations nest and read like operations in a more conventional programming language. Well, for some definition of conventional: it reads like Scheme (a language in the family of LISPs), and the convention for parenthesization is a clear homage to it. Of course, this is not by accident; if you know a bit about JavaScript\u2019s evil origin story you\u2019ll definitely know that it was originally written in 10 days; and you may also know that Brendan Eich initially was hired to develop a Scheme dialect.<\/p>\n<p>However, the even more interesting detail (at least to me) is that the nested sequence naturally linearizes to the other version; in fact, if you follow the precedence rule for parenthesized expressions, you have to start at the innermost parentheses:<\/p>\n<div id=\"cb5\" class=\"sourceCode\">\n<pre class=\"sourceCode scheme\"> (i32.add \n    (local.get $x) \n    (i32.const 2))<\/pre>\n<\/div>\n<p>so first you get <code>$x<\/code>, then you evaluate the constant to <code>2<\/code>, then you sum them; then you continue with the outermost expression:<\/p>\n<div id=\"cb6\" class=\"sourceCode\">\n<pre class=\"sourceCode scheme\">(i32.mul \n  (i32.add ...) \n  (i32.const 3))<\/pre>\n<\/div>\n<p>Now you have evaluated the contained <code>i32.add<\/code>, you evaluate the constant <code>3<\/code> and you can multiply them. That\u2019s exactly the same order of evaluation of the stack-based version!<\/p>\n<p>We have also mentioned structured control flow. The reason for this choice is, again, safety; but also <a href=\"https:\/\/github.com\/WebAssembly\/design\/blob\/main\/Rationale.md\">simplicity<\/a>:<\/p>\n<blockquote><p>The WebAssembly stack machine is restricted to structured control flow and structured use of the stack. This greatly simplifies one-pass verification, avoiding a fixpoint computation like that of other stack machines such as the Java Virtual Machine (prior to stack maps). This also simplifies compilation and manipulation of WebAssembly code by other tools.<\/p><\/blockquote>\n<p>Let\u2019s see an example:<\/p>\n<div id=\"cb7\" class=\"sourceCode\">\n<pre class=\"sourceCode java\"> void print(boolean x) {\n    if (x) {\n        System.out.println(1);\n    } else {\n        System.out.println(0);\n    }\n}<\/pre>\n<\/div>\n<p>This translates to the bytecode:<\/p>\n<div id=\"cb8\" class=\"sourceCode\">\n<pre class=\"sourceCode asm\"> void print(boolean);\n Code:\n 0: iload_1\n 1: ifeq 14\n 4: getstatic #7 \/\/ java\/lang\/System.out:Ljava\/io\/PrintStream;\n 7: iconst_1\n 8: invokevirtual #13 \/\/ java\/io\/PrintStream.println:(I)V\n11: goto 21\n14: getstatic #7 \/\/ java\/lang\/System.out:Ljava\/io\/PrintStream;\n17: iconst_0\n18: invokevirtual #13 \/\/ java\/io\/PrintStream.println:(I)V\n21: return<\/pre>\n<\/div>\n<p>You will notice the unstructured jump instructions <code>ifeq<\/code>\u00a0 and <code>goto<\/code> which are missing from the equivalent WebAssembly definition, replaced instead by proper <code>if...then...else<\/code> blocks!<\/p>\n<div id=\"cb9\" class=\"sourceCode\">\n<pre class=\"sourceCode scheme\">(module\n ;; import the browser console object, \n ;; you'll need to pass this in from JavaScript\n (import \"console\" \"log\" (func $log (param i32)))\n\n (func\n   ;; change to positive number (true) \n   ;; if you want to run the if block\n   (i32.const 0) \n   (call 0))\n\n  (func (param i32)\n   local.get 0 \n   (if\n     (then\n       i32.const 1\n       call $log ;; should log '1'\n     )\n     (else\n       i32.const 0\n       call $log ;; should log '0'\n     )))\n\n (start 1) ;; run the first function automatically\n)\n<\/pre>\n<\/div>\n<p>You can see and play with the original example on the <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/WebAssembly\/Reference\/Control_flow\/if...else\">Mozilla Developer Network<\/a><\/p>\n<p>Obviously, this also linearizes to a non-nested version:<\/p>\n<div id=\"cb10\" class=\"sourceCode\">\n<pre class=\"sourceCode scheme\">(module\n  (type (;0;) (func (param i32)))\n  (type (;1;) (func))\n  (import \"console\" \"log\" (func (;0;) (type 0)))\n  (func (;1;) (type 1)\n    i32.const 1\n    call 0)\n  (func (;2;) (type 0) (param i32)\n    local.get 0\n    if  ;; label = @1\n      i32.const 1\n      call 0\n    else\n      i32.const 0\n      call 0\n    end)\n  (start 1))\n<\/pre>\n<\/div>\n<h2 id=\"more-differences-memory-management\">More Differences: Memory Management<\/h2>\n<p>For better or worse, another area where WebAssembly virtual machines greatly differ from a JVM is <strong>memory management<\/strong>. As you probably know, Java languages do not require you to allocate and deallocate memory, or care about stack vs. heap allocations; at least in general: you may care about those and there are ways to deal with them explicitly if you really need to. But the reality is that most people won\u2019t.<\/p>\n<p>This is not a language-level feature, it is really also how the VM works. You do not have primitives to deal with memory at the VM-level; in fact, primitives for heap allocation are available, but they are exposed as JDK APIs. There is no way for you to opt out of managed memory: you cannot just say \u201cI don\u2019t care about the garbage collected heap, I am going to do my own memory management\u201d.<\/p>\n<p>At this time, WebAssembly is quite the opposite. It is no coincidence that <em>most<\/em> languages targeting WebAssembly today really manage their own memory. Some languages do garbage collection; but in those cases, they have to roll their own garbage collection routines, because the VM does not provide such a facility.<\/p>\n<p>Instead, with WebAssembly you get a slice of <em>linear memory,<\/em> and then you can do whatever you want with it. Allocate, deallocate; even move it around if you\u2019d like. While this is, in a way, more powerful than what the JVM provides, it also comes with caveats.<\/p>\n<p>For instance, the JVM does not require you to specify the memory layout of an object, because it is up to the VM to deal with structure packing, word alignment, etc. In the case of WebAssembly, <em>you<\/em> deal with those issues.<\/p>\n<p>On the one hand, this makes it perfect as a target for manually-managed programming languages, where a higher degree of control is expected and desired. On the other hand, it could make it harder for such languages to <em>interoperate<\/em> with each other.<\/p>\n<p>Now, structure and object layout is an <strong>ABI<\/strong> concern: <a href=\"https:\/\/docs.oracle.com\/javase\/specs\/jls\/se7\/html\/jls-13.html\">a thing of the past for JVM developers, except for some very limited and notable exceptions<\/a>.<\/p>\n<p>Interestingly enough, the <a href=\"https:\/\/github.com\/WebAssembly\/gc\">draft GC spec for WebAssembly has recently moved forwards<\/a>, and it does not just deal with garbage collection, but it effectively describes how to deal with <strong>structures<\/strong>, and how to make them interoperate, regardless of the originating language. So, while this is still not ready, things are continuously evolving and multiple concerns are being addressed.<\/p>\n<h2 id=\"more-than-web\">More Than Web<\/h2>\n<p><a href=\"https:\/\/www.youtube.com\/watch?v=UrIiLvg58SY\"><img data-recalc-dims=\"1\" decoding=\"async\" style=\"float: right\" src=\"https:\/\/i0.wp.com\/i.imgur.com\/P6BMCD1.png?w=400&#038;ssl=1\"  \/><\/a><\/p>\n<p>Now, in all we have learned so far, you might have noticed that I never mentioned the word Web once.<\/p>\n<p>Indeed, it took me a while to get to the point, but <strong>this is where I tell you, the Java Geek, why you should care<\/strong>.<\/p>\n<p>Even if you do not care about front-end, you should not dismiss WebAssembly as a purely front-end technology. <strong>There is nothing in the design and specification of WebAssembly that makes it specifically tied to the front-end.<\/strong> In fact, most mainstream JavaScript runtimes are now able to load and link WebAssembly binaries, even outside the browser; so you can run a Wasm executable in a Node.js runtime, with a thin layer of JS glue code to interact with the rest of the platform.<\/p>\n<p>But there are also many <strong>pure-WebAssembly runtimes<\/strong>, such as <a href=\"https:\/\/wasmtime.dev\/\">Wasmtime<\/a>, <a href=\"https:\/\/wasmedge.org\/\">WasmEdge<\/a>,\u00a0<a href=\"https:\/\/wazero.io\/\">Wazero<\/a> that are completely untied from a JavaScript host. These runtimes are usually lighter-weight than a full-blown JavaScript engine, and they are often easy to embed inside larger projects.<\/p>\n<p>In fact, <strong>many projects are starting to embrace WebAssembly as a polyglot platform to host extensions and plug-ins.<\/strong><\/p>\n<p>One notable example, for instance, is the<strong> <a href=\"https:\/\/www.envoyproxy.io\/\">Envoy proxy<\/a>:<\/strong> the codebase is mostly C++; it does support plug-ins, but with the same caveats as browser plug-ins: you have to compile them, you have to ship them, they may not run at the right level of privileges, they may even tear down the entire process in case of a fatal fault. Now, you could embed a Lua or a JS interpreter and let your users script their way to success: the interpreter is safer because it is isolated from your main business logic, and it only interacts in a safe way with the host environment; the main downside: you have to pick a language for your users.<\/p>\n<p>Or, you could just embed a WebAssembly runtime, let your users pick their own language and <em>just compile it to Wasm<\/em>. You will have the same safety guarantees, and happier users.<\/p>\n<p>These pure WebAssembly runtimes are not just for extensions. Many projects are creating thin layers of Wasm-native APIs to provide <strong>stand-alone platforms.<\/strong><\/p>\n<p>For instance, <a href=\"https:\/\/wasmcloud.com\/\">wasmCloud<\/a> is a distributed platform for writing portable business logic that can run anywhere from the edge to the cloud.<\/p>\n<p><a href=\"https:\/\/docs.fastly.com\/products\/compute-at-edge\">Fastly<\/a> has developed a platform for serverless computing at the edge, where the serverless functions are implemented by user-provided WebAssembly executables.<\/p>\n<p><a href=\"https:\/\/www.fermyon.com\/\">Fermyon<\/a> is a startup that is developing a rich ecosystem of tooling and Web-based APIs to write Web apps using only Wasm. One of their latest announcement is their <a href=\"https:\/\/www.fermyon.com\/cloud\">Fermyon Cloud<\/a> offering.<\/p>\n<p>These solutions offer custom, ad-hoc APIs for specific use cases; and this is indeed one way to use WebAssembly. But that is not the end of it. In 2019, Docker founder Solomon Hykes wrote:<\/p>\n<blockquote class=\"twitter-tweet\">\n<p dir=\"ltr\" lang=\"en\">If WASM+WASI existed in 2008, we wouldn&#8217;t have needed to created Docker. That&#8217;s how important it is. Webassembly on the server is the future of computing. A standardized system interface was the missing link. Let&#8217;s hope WASI is up to the task! <a href=\"https:\/\/t.co\/wnXQg4kwa4\">https:\/\/t.co\/wnXQg4kwa4<\/a><\/p>\n<p>\u2014 Solomon Hykes (@solomonstre) <a href=\"https:\/\/twitter.com\/solomonstre\/status\/1111004913222324225?ref_src=twsrc%5Etfw\">March 27, 2019<\/a><\/p><\/blockquote>\n<p><a href=\"https:\/\/platform.twitter.com\/widgets.js\">https:\/\/platform.twitter.com\/widgets.js<\/a><\/p>\n<p>If you pull this out of context your first question may be \u201cWhat the hell has Wasm to do with Docker?\u201d and, of course, \u201cWhat the hell is WASI?\u201d.<\/p>\n<p>WASI is the <em>WebAssembly System Interface<\/em>. You can think of it as of a collection of (POSIX-like) APIs that allow a Wasm runtime to interact with the operating system. Is this like the JDK Class Library? Not quite. It is a thin layer of capability-oriented APIs for interaction with the operating system. You can read more on the <a href=\"https:\/\/hacks.mozilla.org\/2019\/03\/standardizing-wasi-a-webassembly-system-interface\/\">Mozilla announcement blog.<\/a>, but, in short, this is the last piece of the puzzle: WASI allows to define backend applications that directly interact with the operating system without any extra layer, and without ad-hoc APIs. The current effort is to make WASI widely-adopted and, in a way, a standard <em>de facto<\/em> for backend development.<\/p>\n<p>WASI APIs include things like file system access, networking and even threading APIs. These APIs work hand-in-hand with the lower-level capabilities of the runtime, enabling easier ports to the platform.<\/p>\n<h2 id=\"porting-java\">Porting Java<\/h2>\n<p>With all its challenges, for the first time, we have a technology with the potential to become a truly multi-vendor, multi-platform, safe, polyglot programming platform. I believe that we, as Java geeks, should not lose the occasion to be relevant in this space.<\/p>\n<p>The WebAssembly specification and the WASI effort are still in flux. But all these pieces together are paving the way to allow an easier port of any programming language, not just those with a manual memory management.<\/p>\n<p>Indeed, some garbage collected languages are already available, albeit not all of them take the same approach. For instance, Go can be compiled to Wasm (albeit with some limitations). For instance, the Python port is a port of <em>the interpreter<\/em>. So they compiled the CPython interpreter to Wasm, and <em>then<\/em> that is used to evaluate Python scripts, just like in a traditional execution environment.<\/p>\n<p>In fact, memory management is really just part of the story, and only one of the many caveats that at this time would allow to port Java. You can always stick a GC in your executable (indeed, this is how GraalVM Native Image currently work); in my opinion, however it is harder to support other CPU features or system calls that are currently still unstable or not widely supported.<\/p>\n<p>For instance:<br \/>\n&#8211; threading support is still lacking or experimental in most stand-alone Wasm runtimes;<br \/>\n&#8211; even browser support is experimental, and simulated through WebWorkers.<br \/>\n&#8211; there is not a standardized support for socket access: all the services that allow you to write custom HTTP handlers usually provides you with a pre-configured socket, limiting low-level access<br \/>\n&#8211; Exception handling is another experimental feature that is harder to simulate, because of the lack of unstructured jumps in the Wasm bytecode: this will likely need proper support in Wasm VMs before it can be adopted.<br \/>\n&#8211; each language brings its own constraints on memory layout and object shapes: it is therefore harder for languages to share data across boundaries, hindering compatibility between different languages and thus limiting the suitability of Wasm as a polyglot plaform (this is however being addressed as part of the GC spec itself).<\/p>\n<p>In short, there are many challenges to porting Java to the WebAssembly platform inside and outside the browser.<\/p>\n<h2 id=\"java-support-on-webassembly\">Java Support on WebAssembly<\/h2>\n<p>Currently, multiple projects and library that deal with WebAssembly and Java. I have compiled a list of those that I found around the web. At this time, however, most of these are hobby projects.<\/p>\n<h3 id=\"running-java-in-the-browser\">Running Java in the Browser<\/h3>\n<p>Many projects target Java translation to WebAssembly. Most of them, however, do not emit code that is compatible with leaner Wasm runtimes: in general, they are meant for running in the browser.<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/mirkosertic\/Bytecoder\">Bytecoder<\/a>, <a href=\"https:\/\/github.com\/i-net-software\/JWebAssembly\">JWebAssembly<\/a>, and <a href=\"https:\/\/teavm.org\/\">TeaVM<\/a> are all translators from Java bytecode into WebAssembly that take a slightly different approach to translating Java bytecode to browser-friendly code. Among the others, <a href=\"https:\/\/teavm.org\/\">TeaVM<\/a> seems the most promising, as shown in <a href=\"https:\/\/github.com\/fermyon\/teavm-wasi\">Fermyon\u2019s fork which includes initial support for WASI<\/a><\/li>\n<li><a href=\"https:\/\/leaningtech.com\/cheerpj\/\">CheerpJ<\/a> is a very promising, albeit proprietary, attempt to support the full extent of Java, including Swing. There is also a <a href=\"https:\/\/chrome.google.com\/webstore\/detail\/cheerpj-applet-runner\/bbmolahhldcbngedljfadjlognfaaein\">Chrome extension to run good ol\u2019 applets through Web tech<\/a><\/li>\n<\/ul>\n<p>Here are also some honorable mentions of projects that target browser runtimes (with experimental Wasm support in some cases):<\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/google\/j2cl\/tree\/master\/samples\/wasm\/src\/main\/java\/com\/google\/j2cl\/samples\/wasm\">J2CL (successor to GWT)<\/a> is a source-to-source translator (i.e.\u00a0a <em>transpiler<\/em>) from Java to JavaScript, which has recently gained support for Wasm. This compiler has also bleeding-edge support for the GC spec.<\/li>\n<li><a href=\"https:\/\/github.com\/jtulach\/bck2brwsr\">Bck2Brwsr<\/a> is another compiler from bytecode that targets JavaScript and the browser<\/li>\n<li><a href=\"https:\/\/www.fermyon.com\/wasm-languages\/kotlin\">Kotlin\/Native<\/a> also supports being compiled to Wasm via LLVM. It comes with all the caveats of Kotlin\/Native (e.g.\u00a0it may not support all of your Java libraries)<\/li>\n<li><a href=\"https:\/\/plasma-umass.org\/doppio-demo\/\">DoppioJVM<\/a> is an interesting project that I wish to mention because it takes a completely different approach, <a href=\"https:\/\/www.fermyon.com\/wasm-languages\/python\">similar to Python\u2019s<\/a>: instead of compiling bytecode to Wasm, it is instead an in-browser VM (written in JavaScript) that is able to interpret JVM bytecode. Unfortunately, the project is currently unmaintained.<\/li>\n<\/ul>\n<h3 id=\"running-webassembly-on-the-jvm\">Running WebAssembly on the JVM<\/h3>\n<p>We have been talking about running Java programs on a Wasm runtime. But of course, you may want to be able to do the opposite, too. In all fairness, the JVM already provides quite a few programming languages, and the current programming model that most Wasm runtimes offer (with manual memory management) seems kind of off when hosted on a JVM. But I still want to mention these for completeness, and because in general, they may still be interesting.<\/p>\n<ul>\n<li>The prime candidate is obviously the aforementioned <a href=\"https:\/\/github.com\/oracle\/graal\/tree\/master\/wasm\">GraalVM\u2019s Truffle implementation of a WebAssembly interpreter<\/a>, which benefits from all the JIT superpowers and polyglot interoperability of the GraalVM\/Truffle platform<\/li>\n<li><a href=\"https:\/\/github.com\/cretz\/asmble\">asmble<\/a> is a suite of tools that includes a compiler from Wasm to bytecode and a Wasm interpreter<\/li>\n<li><a href=\"https:\/\/github.com\/fishjd\/HappyNewMoonWithReport\">Happy New Moon With Report (JVM)<\/a> is a WebAssembly runtime for the JVM (that I am including in this list because I just love the silly name!)<\/li>\n<li>There are also bindings to native Wasm runtimes, such as <a href=\"https:\/\/github.com\/kawamuray\/wasmtime-java\">kawamuray\/wasmtime-java<\/a><\/li>\n<li>The <a href=\"https:\/\/extism.org\/\">Extism project<\/a> has recently launched: it provides a unified API across different host languages to interface with a native WebAssembly runtime (Wasmtime)<\/li>\n<li><a href=\"https:\/\/github.com\/evacchi\/kaitai-webassembly\">Katai WebAssembly<\/a> is a Wasm parser written using the <a href=\"https:\/\/kaitai.io\/\">Katai Struct<\/a> binary parser generator that I am currently maintaining (PRs welcome!): this is not meant necessarily for <em>running<\/em> Wasm on the JVM, but it is actually useful when you want to be able to manipulate or query Wasm executables for information. In fact, a Kaitai grammar allows one to generate a binary parser for any supported language, so not just Java, but also Python, Ruby, Go, C++, and many others.<\/li>\n<\/ul>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>I hope that this post sparked some interest in you. It is still early days for Java-on-Wasm, but I invite you to explore this brand-new world with an open mind: it may surprise you!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When many Java developers hear the word WebAssembly, the first thing they think is \u201cbrowser technology\u201d. The second thing: \u201cit\u2019s the JVM all over again\u201d. After all, for a Java developer, in-browser apps are prehistory.<\/p>\n","protected":false},"author":218,"featured_media":3226,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[646],"tags":[657,655,656,658,654,653],"coauthors":[579],"class_list":["post-3611","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jvm-advent-2022","tag-backend","tag-browser","tag-client","tag-server","tag-wasm","tag-webassembly"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>WebAssembly for the Java Geek - JVM Advent<\/title>\n<meta name=\"description\" content=\"When many Java developers hear the word WebAssembly, the first thing they think is \u201cbrowser technology\u201d. The second thing: \u201cit\u2019s the JVM all over again\u201d. After all, for a Java developer, in-browser apps are prehistory.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javaadvent.com\/2022\/12\/webassembly-for-the-java-geek.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"WebAssembly for the Java Geek - JVM Advent\" \/>\n<meta property=\"og:description\" content=\"When many Java developers hear the word WebAssembly, the first thing they think is \u201cbrowser technology\u201d. The second thing: \u201cit\u2019s the JVM all over again\u201d. After all, for a Java developer, in-browser apps are prehistory.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javaadvent.com\/2022\/12\/webassembly-for-the-java-geek.html\" \/>\n<meta property=\"og:site_name\" content=\"JVM Advent\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Java-Advent-Calendar-229536173843473\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-12-23T01:01:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-11T16:19:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-23.png\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"800\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Edoardo Vacchi\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/evacchi\" \/>\n<meta name=\"twitter:site\" content=\"@javaadvent\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Edoardo Vacchi\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"17 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/2022\\\/12\\\/webassembly-for-the-java-geek.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/2022\\\/12\\\/webassembly-for-the-java-geek.html\"},\"author\":{\"name\":\"Edoardo Vacchi\",\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/#\\\/schema\\\/person\\\/01e45e233dd0d2a02fb2754dbd331691\"},\"headline\":\"WebAssembly for the Java Geek\",\"datePublished\":\"2022-12-23T01:01:00+00:00\",\"dateModified\":\"2023-01-11T16:19:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/2022\\\/12\\\/webassembly-for-the-java-geek.html\"},\"wordCount\":3394,\"commentCount\":6,\"image\":{\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/2022\\\/12\\\/webassembly-for-the-java-geek.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/www.javaadvent.com\\\/content\\\/uploads\\\/2021\\\/12\\\/Feature-Image-Day-23.png?fit=800%2C800&ssl=1\",\"keywords\":[\"backend\",\"browser\",\"client\",\"server\",\"wasm\",\"webassembly\"],\"articleSection\":[\"2022\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javaadvent.com\\\/2022\\\/12\\\/webassembly-for-the-java-geek.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/2022\\\/12\\\/webassembly-for-the-java-geek.html\",\"url\":\"https:\\\/\\\/www.javaadvent.com\\\/2022\\\/12\\\/webassembly-for-the-java-geek.html\",\"name\":\"WebAssembly for the Java Geek - JVM Advent\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/2022\\\/12\\\/webassembly-for-the-java-geek.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/2022\\\/12\\\/webassembly-for-the-java-geek.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/www.javaadvent.com\\\/content\\\/uploads\\\/2021\\\/12\\\/Feature-Image-Day-23.png?fit=800%2C800&ssl=1\",\"datePublished\":\"2022-12-23T01:01:00+00:00\",\"dateModified\":\"2023-01-11T16:19:04+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/#\\\/schema\\\/person\\\/01e45e233dd0d2a02fb2754dbd331691\"},\"description\":\"When many Java developers hear the word WebAssembly, the first thing they think is \u201cbrowser technology\u201d. The second thing: \u201cit\u2019s the JVM all over again\u201d. After all, for a Java developer, in-browser apps are prehistory.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/2022\\\/12\\\/webassembly-for-the-java-geek.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javaadvent.com\\\/2022\\\/12\\\/webassembly-for-the-java-geek.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/2022\\\/12\\\/webassembly-for-the-java-geek.html#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/www.javaadvent.com\\\/content\\\/uploads\\\/2021\\\/12\\\/Feature-Image-Day-23.png?fit=800%2C800&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/www.javaadvent.com\\\/content\\\/uploads\\\/2021\\\/12\\\/Feature-Image-Day-23.png?fit=800%2C800&ssl=1\",\"width\":800,\"height\":800},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/2022\\\/12\\\/webassembly-for-the-java-geek.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javaadvent.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"WebAssembly for the Java Geek\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javaadvent.com\\\/\",\"name\":\"JVM Advent\",\"description\":\"The JVM Programming Advent Calendar\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javaadvent.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javaadvent.com\\\/#\\\/schema\\\/person\\\/01e45e233dd0d2a02fb2754dbd331691\",\"name\":\"Edoardo Vacchi\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d4267d225c12ceb6e2689dce9f5d966fda17e2e37176c6fa1cb06a8d22282643?s=96&d=retro&r=g5e5cd6c1eeeb76b6cccaee5714b8beab\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d4267d225c12ceb6e2689dce9f5d966fda17e2e37176c6fa1cb06a8d22282643?s=96&d=retro&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d4267d225c12ceb6e2689dce9f5d966fda17e2e37176c6fa1cb06a8d22282643?s=96&d=retro&r=g\",\"caption\":\"Edoardo Vacchi\"},\"description\":\"After my PhD at University of Milan on programming language design and implementation, I worked for three years at UniCredit Bank's R&amp;D department. Later, I have joined Red Hat where I worked on the Drools rule engine, the jBPM workflow engine and the Kogito cloud-native business automation platform. I joined Tetrate to work on the wazero WebAssembly runtime for Go. At Dylibso I contributed to wazero and Chicory Wasm runtime for the JVM, and other runtimes! I am currently back at Red Hat AI. I sometimes write on my own personal blog.\",\"sameAs\":[\"https:\\\/\\\/evacchi.github.io\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/edoardovacchi\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/evacchi\"],\"url\":\"https:\\\/\\\/www.javaadvent.com\\\/author\\\/evacchi\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"WebAssembly for the Java Geek - JVM Advent","description":"When many Java developers hear the word WebAssembly, the first thing they think is \u201cbrowser technology\u201d. The second thing: \u201cit\u2019s the JVM all over again\u201d. After all, for a Java developer, in-browser apps are prehistory.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javaadvent.com\/2022\/12\/webassembly-for-the-java-geek.html","og_locale":"en_US","og_type":"article","og_title":"WebAssembly for the Java Geek - JVM Advent","og_description":"When many Java developers hear the word WebAssembly, the first thing they think is \u201cbrowser technology\u201d. The second thing: \u201cit\u2019s the JVM all over again\u201d. After all, for a Java developer, in-browser apps are prehistory.","og_url":"https:\/\/www.javaadvent.com\/2022\/12\/webassembly-for-the-java-geek.html","og_site_name":"JVM Advent","article_publisher":"https:\/\/www.facebook.com\/Java-Advent-Calendar-229536173843473\/","article_published_time":"2022-12-23T01:01:00+00:00","article_modified_time":"2023-01-11T16:19:04+00:00","og_image":[{"width":800,"height":800,"url":"https:\/\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-23.png","type":"image\/png"}],"author":"Edoardo Vacchi","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/evacchi","twitter_site":"@javaadvent","twitter_misc":{"Written by":"Edoardo Vacchi","Est. reading time":"17 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javaadvent.com\/2022\/12\/webassembly-for-the-java-geek.html#article","isPartOf":{"@id":"https:\/\/www.javaadvent.com\/2022\/12\/webassembly-for-the-java-geek.html"},"author":{"name":"Edoardo Vacchi","@id":"https:\/\/www.javaadvent.com\/#\/schema\/person\/01e45e233dd0d2a02fb2754dbd331691"},"headline":"WebAssembly for the Java Geek","datePublished":"2022-12-23T01:01:00+00:00","dateModified":"2023-01-11T16:19:04+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javaadvent.com\/2022\/12\/webassembly-for-the-java-geek.html"},"wordCount":3394,"commentCount":6,"image":{"@id":"https:\/\/www.javaadvent.com\/2022\/12\/webassembly-for-the-java-geek.html#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-23.png?fit=800%2C800&ssl=1","keywords":["backend","browser","client","server","wasm","webassembly"],"articleSection":["2022"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javaadvent.com\/2022\/12\/webassembly-for-the-java-geek.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javaadvent.com\/2022\/12\/webassembly-for-the-java-geek.html","url":"https:\/\/www.javaadvent.com\/2022\/12\/webassembly-for-the-java-geek.html","name":"WebAssembly for the Java Geek - JVM Advent","isPartOf":{"@id":"https:\/\/www.javaadvent.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javaadvent.com\/2022\/12\/webassembly-for-the-java-geek.html#primaryimage"},"image":{"@id":"https:\/\/www.javaadvent.com\/2022\/12\/webassembly-for-the-java-geek.html#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-23.png?fit=800%2C800&ssl=1","datePublished":"2022-12-23T01:01:00+00:00","dateModified":"2023-01-11T16:19:04+00:00","author":{"@id":"https:\/\/www.javaadvent.com\/#\/schema\/person\/01e45e233dd0d2a02fb2754dbd331691"},"description":"When many Java developers hear the word WebAssembly, the first thing they think is \u201cbrowser technology\u201d. The second thing: \u201cit\u2019s the JVM all over again\u201d. After all, for a Java developer, in-browser apps are prehistory.","breadcrumb":{"@id":"https:\/\/www.javaadvent.com\/2022\/12\/webassembly-for-the-java-geek.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javaadvent.com\/2022\/12\/webassembly-for-the-java-geek.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javaadvent.com\/2022\/12\/webassembly-for-the-java-geek.html#primaryimage","url":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-23.png?fit=800%2C800&ssl=1","contentUrl":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-23.png?fit=800%2C800&ssl=1","width":800,"height":800},{"@type":"BreadcrumbList","@id":"https:\/\/www.javaadvent.com\/2022\/12\/webassembly-for-the-java-geek.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javaadvent.com\/"},{"@type":"ListItem","position":2,"name":"WebAssembly for the Java Geek"}]},{"@type":"WebSite","@id":"https:\/\/www.javaadvent.com\/#website","url":"https:\/\/www.javaadvent.com\/","name":"JVM Advent","description":"The JVM Programming Advent Calendar","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javaadvent.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.javaadvent.com\/#\/schema\/person\/01e45e233dd0d2a02fb2754dbd331691","name":"Edoardo Vacchi","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/d4267d225c12ceb6e2689dce9f5d966fda17e2e37176c6fa1cb06a8d22282643?s=96&d=retro&r=g5e5cd6c1eeeb76b6cccaee5714b8beab","url":"https:\/\/secure.gravatar.com\/avatar\/d4267d225c12ceb6e2689dce9f5d966fda17e2e37176c6fa1cb06a8d22282643?s=96&d=retro&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d4267d225c12ceb6e2689dce9f5d966fda17e2e37176c6fa1cb06a8d22282643?s=96&d=retro&r=g","caption":"Edoardo Vacchi"},"description":"After my PhD at University of Milan on programming language design and implementation, I worked for three years at UniCredit Bank's R&amp;D department. Later, I have joined Red Hat where I worked on the Drools rule engine, the jBPM workflow engine and the Kogito cloud-native business automation platform. I joined Tetrate to work on the wazero WebAssembly runtime for Go. At Dylibso I contributed to wazero and Chicory Wasm runtime for the JVM, and other runtimes! I am currently back at Red Hat AI. I sometimes write on my own personal blog.","sameAs":["https:\/\/evacchi.github.io","https:\/\/www.linkedin.com\/in\/edoardovacchi","https:\/\/x.com\/https:\/\/twitter.com\/evacchi"],"url":"https:\/\/www.javaadvent.com\/author\/evacchi"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-23.png?fit=800%2C800&ssl=1","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":6289,"url":"https:\/\/www.javaadvent.com\/2025\/12\/chicory-webassembly-on-the-jvm.html","url_meta":{"origin":3611,"position":0},"title":"Bring WebAssembly to the JVM. How Chicory Is Powering a New Generation of Java Libraries","author":"Andrea Peruffo","date":"December 23, 2025","format":false,"excerpt":"Introduction: the promise of \u201cembed once, run anywhere\u201d reimagined \u00a0 What if you could embed native\u2011level capabilities into your Java applications, think of database engines, scripting runtimes, policy interpreters, even compilers and still remain pure Java, with no JNI, no native binaries, no concerns about OS or architecture compatibility? That\u2026","rel":"","context":"In &quot;2017&quot;","block_context":{"text":"2017","link":"https:\/\/www.javaadvent.com\/category\/2017"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-23.png?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-23.png?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-23.png?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-23.png?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":5722,"url":"https:\/\/www.javaadvent.com\/2024\/12\/wasm-chicory-1.html","url_meta":{"origin":3611,"position":1},"title":"The Chicory Photo Album: Celebrating 1.0.0 and a Year of Wasm","author":"Andrea Peruffo","date":"December 25, 2024","format":false,"excerpt":"Intro Christmas is a time of tradition, and I\u2019m delighted to continue the one we started last year. On this very same date and blog, we unveiled the development of Chicory: Chicory: WebAssembly on the JVM. WebAssembly continues to grow steadily and strongly, much like we\u2019ve come to expect from\u2026","rel":"","context":"In &quot;2024&quot;","block_context":{"text":"2024","link":"https:\/\/www.javaadvent.com\/category\/2024"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2022\/12\/Feature-Image-Day-25.webp?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2022\/12\/Feature-Image-Day-25.webp?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2022\/12\/Feature-Image-Day-25.webp?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2022\/12\/Feature-Image-Day-25.webp?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":4571,"url":"https:\/\/www.javaadvent.com\/2023\/12\/a-return-to-webassembly-for-the-java-geek.html","url_meta":{"origin":3611,"position":2},"title":"A Return to WebAssembly for the Java Geek","author":"Edoardo Vacchi","date":"December 5, 2023","format":false,"excerpt":"Welcome back, my dear\u00a0Java Geek! Last year we compared WebAssembly and discussed in what ways it differs from the JVM. A lot of things have happened in the meantime. If you want to dive deeper into that kind of detail, I warmly suggest reading this beautiful blog series by Chris\u2026","rel":"","context":"In &quot;2023&quot;","block_context":{"text":"2023","link":"https:\/\/www.javaadvent.com\/category\/2023"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-5.png?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-5.png?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-5.png?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2021\/12\/Feature-Image-Day-5.png?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":5014,"url":"https:\/\/www.javaadvent.com\/2023\/12\/chicory-wasm-jvm.html","url_meta":{"origin":3611,"position":3},"title":"A zero dependency Wasm runtime for the JVM","author":"Andrea Peruffo","date":"December 25, 2023","format":false,"excerpt":"All I want for Xmas is Chicory INTRO In a lot of cultures, during Christmas time, Santa would distribute toys and presents to the good kids around. If you are reading Java Advent Of Code, that means that you care about Java and I\u2019m sure you are a good one\u2026","rel":"","context":"In &quot;@Primary&quot;","block_context":{"text":"@Primary","link":"https:\/\/www.javaadvent.com\/category\/primary"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2022\/12\/Feature-Image-Day-25.webp?fit=800%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2022\/12\/Feature-Image-Day-25.webp?fit=800%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2022\/12\/Feature-Image-Day-25.webp?fit=800%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2022\/12\/Feature-Image-Day-25.webp?fit=800%2C800&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":5083,"url":"https:\/\/www.javaadvent.com\/2024\/12\/wasm-4-the-java-geek-3-electric-boogaloo.html","url_meta":{"origin":3611,"position":4},"title":"Wasm 4 the Java Geek 3: Electric Boogaloo","author":"Edoardo Vacchi","date":"December 18, 2024","format":false,"excerpt":"\u00a0 And here we are again. For the third time in a row, we are back to the Java Advent, eager to discover what\u2019s new with WebAssembly from a Java developer perspective. Incidentally, since, as you know, I have a favorite topic (after programming languages and compilers, of course), it\u2026","rel":"","context":"In &quot;2024&quot;","block_context":{"text":"2024","link":"https:\/\/www.javaadvent.com\/category\/2024"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2024\/12\/wasm-4-java-geek-3.jpg?fit=1200%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2024\/12\/wasm-4-java-geek-3.jpg?fit=1200%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2024\/12\/wasm-4-java-geek-3.jpg?fit=1200%2C800&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2024\/12\/wasm-4-java-geek-3.jpg?fit=1200%2C800&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2024\/12\/wasm-4-java-geek-3.jpg?fit=1200%2C800&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":1880,"url":"https:\/\/www.javaadvent.com\/2019\/12\/smalltalk-with-the-graalvm.html","url_meta":{"origin":3611,"position":5},"title":"Smalltalk with the GraalVM","author":"Fabio Niephaus","date":"December 7, 2019","format":false,"excerpt":"Today, we\u2019re going back to the future and do some Smalltalk with the GraalVM. Introduction The Java HotSpot Performance Engine is one of the most sophisticated process virtual machines (VMs) available and used by millions of Java developers every day. If we go back in the early history of HotSpot,\u2026","rel":"","context":"In &quot;2019&quot;","block_context":{"text":"2019","link":"https:\/\/www.javaadvent.com\/category\/christmas-2019-is-coming"},"img":{"alt_text":"GraalSqueak and GraalVM","src":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/graalvm-and-graalsqueak-updated.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/graalvm-and-graalsqueak-updated.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/graalvm-and-graalsqueak-updated.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.javaadvent.com\/content\/uploads\/2019\/12\/graalvm-and-graalsqueak-updated.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"jetpack_likes_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.javaadvent.com\/wp-json\/wp\/v2\/posts\/3611","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javaadvent.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javaadvent.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javaadvent.com\/wp-json\/wp\/v2\/users\/218"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javaadvent.com\/wp-json\/wp\/v2\/comments?post=3611"}],"version-history":[{"count":23,"href":"https:\/\/www.javaadvent.com\/wp-json\/wp\/v2\/posts\/3611\/revisions"}],"predecessor-version":[{"id":4460,"href":"https:\/\/www.javaadvent.com\/wp-json\/wp\/v2\/posts\/3611\/revisions\/4460"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javaadvent.com\/wp-json\/wp\/v2\/media\/3226"}],"wp:attachment":[{"href":"https:\/\/www.javaadvent.com\/wp-json\/wp\/v2\/media?parent=3611"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javaadvent.com\/wp-json\/wp\/v2\/categories?post=3611"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javaadvent.com\/wp-json\/wp\/v2\/tags?post=3611"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.javaadvent.com\/wp-json\/wp\/v2\/coauthors?post=3611"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}