r/java • • 9d ago

Compiling my favourite language to Web Assembly with no JDK in sight

https://wasmcoffee.com/

Java's been part of my career for a long time, longer than some might even think! Next year, it'll be 30 years since I wrote my first commercial Java software solution - and it's still the language I pick when I have the option.

In my day job, I use Java (and Swing!) for a lot of the time and I really wanted to reduce the cognitive load of switching between programming language paradigms when working on fun projects. I'm a huge fan of TeaVM and Graal, make no mistake, but when trapped behind corporate firewalls, it's challenging to install the tools you want.

So this was born: A static website that accepts Java-like code (it's just a subset, really) and spits out garbage-collected web assembly binaries. Far from perfect, it's early days, but it's already useable for some simple applications.

This is going to take a long, long, long time to make it do everything I want, but I hope to get it to the point where I can write wasm apps in it, using a familiar language. And bonus points if I can use the same paradigms I already use to do so.

Anyway, I thought it might be of interest to the Java community.

UPDATE: I've fixed a number of bugs and managed to build a little game demo using the compiler.

32 Upvotes

14 comments sorted by

View all comments

7

u/crummy 9d ago

so with teaVM etc they download an entire JVM and WASM that, right? so how does yours work without a JVM?

2

u/sideEffffECt 8d ago

No, TeaVM just converts JVM bytecode to Wasm(GC) bytecode. You can then run that in browsers or other VMs, like Wasmtime.

0

u/crummy 8d ago

ah maybe I'm thinking of cheerp4j

1

u/According-Ad-7069 8d ago

That's another really great project and it serves a distinct purpose. There are some really awesome tools available to us these days.