Get the latest tech news

Running Clojure in WASM with GraalVM


from v25 GraalVM added support for WASM backend for Java programs compiled to native image, which means that it's finally becomes possible to compile and run Clojure programs in WASM! Although WASM backend is in its early days, and doesn't support threading and networking, it is already possible to compile and run single-threaded computational programs in Java/Clojure. If you open browser console now, on this page, you'll see Hello, World! printed in the console.

The output WASM of this simple program is 5.6MB binary, which can be pruned a bit via wasm-opt tool, just make sure that it doesn't break anything for you. For detailed analysis GraalVM provides a build report, that says that 70% of compiled output is heap snapshot and roughly 50% of it is filled with strings and hash maps. I'm no expert on WASM and GraalVM, so can't really tell anything in defence of it, but I was also surprised that native image runs slower.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of wasm

wasm

Photo of Clojure

Clojure

Photo of GraalVM

GraalVM

Related news:

News photo

Abusing DuckDB-WASM by making SQL draw 3D graphics (Sort Of)

News photo

Show HN: (bits) of a Libc, Optimized for Wasm

News photo

Show HN: Obelisk – a WASM-based deterministic workflow engine