GWT for a Java to WASM compiler

286 views
Skip to first unread message

Craig Mitchell

unread,
May 12, 2023, 6:27:43 AM5/12/23
to GWT Users
At Google I/O 2023, they showed that WASM (Web Assembly) is finally getting garbage collection (as well as shared memory).


They showed that JetBrains was experimenting with Kotlin compiling to WASM.

There wasn't any mention of anyone doing Java compilation to WASM.

I wonder how hard it would be to modify GWT to compile to WASM.  Possible?  Thoughts?

Gordan Krešić

unread,
May 12, 2023, 6:59:17 AM5/12/23
to google-we...@googlegroups.com
On 12. 05. 2023. 12:27, Craig Mitchell wrote:
>
> There wasn't any mention of anyone doing Java compilation to WASM.
>
> I wonder how hard it would be to modify GWT to compile to WASM.  Possible?  Thoughts?

There is a Wasm compilation target in J2CL, but I haven't ever tried it myself:

https://github.com/google/j2cl
https://github.com/google/j2cl/issues/88
https://github.com/google/j2cl/issues/93 -> according to this one, they are working on their WASM support currently ("Now")

-gkresic.

Thomas Broyer

unread,
May 12, 2023, 12:30:51 PM5/12/23
to GWT Users
Also, TeaVM does Java → WebAssembly (WASM or WASI)
No idea if it already leverages WASM-GC or it's in their roadmap

Craig Mitchell

unread,
May 12, 2023, 6:34:33 PM5/12/23
to GWT Users
Awesome!  Looks like J2CL is on it!  🎉

From memory, TeaVM has had WASM in an undocumented  and experimental status for a few years now.  I won't be holding my breath for that one.  🙂

Thomas Broyer

unread,
May 12, 2023, 7:29:45 PM5/12/23
to GWT Users
On Saturday, May 13, 2023 at 12:34:33 AM UTC+2 ma...@craig-mitchell.com wrote:

From memory, TeaVM has had WASM in an undocumented  and experimental status for a few years now.  I won't be holding my breath for that one.  🙂

Well, at least it's documented now 😉 

lofid...@gmail.com

unread,
May 14, 2023, 7:50:58 AM5/14/23
to GWT Users
Thanks for the info. A very good explanation in that video.

But still don't understand why would this solution with WASM GC 2x faster than the "pure transpiling" solution? The latter is completely in JS and uses the GC from JS as it is.

Does this means using JS with WASM will be 2x faster than the pure JS??? 🤣

Thanks 
Lofi

Craig Mitchell

unread,
May 16, 2023, 7:10:14 AM5/16/23
to GWT Users
I think the advantages come from transpiling languages other than JS to WASM (in their examples, Kotlin and Dart).  Eg: An integer in Java, will still be in integer in WASM, while when you ask GWT for an integer, it has to do a bunch of magic, as JS doesn't have integers.
Reply all
Reply to author
Forward
0 new messages