Live data from Hacker News

New Java to WASM GC Transpiler: Run Java in the Browser, No Plugin Required

teavm.org

11–20 of 59 posts

Re: New Java to WASM GC Transpiler: Run Java in the Browser, No Plugin Required

#13
post #5

Love the concept but no clear idea of a use case. Could you list 3 or 4 of them please?

JS frontend enthusiasts rationalized JS on the backend. Now Java backend enthusiasts can once again rationalize Java on the frontend.

I would consider this for a project where I already have Java code on the backend and rewriting it for the front end in JS is a bigger barrier than adding TeaVM to the stack.

Re: New Java to WASM GC Transpiler: Run Java in the Browser, No Plugin Required

#14
post #2

The new release of TeaVM (0.11.0) now supports WebAssembly GC. This increases performance while further decoupling TeaVM apps from ECMAScript. TeaVM ( https://teavm.org/ ) is an Apache-licensed project, free for use in commercial projects. It is mature and used widely, including in frameworks like Flavour ( https://frequal.com/Flavour/book.html ) and more projects listed here: https://www.frequal.com/TeaVM/TeaVmBased…

whats the status of swing? can we port old applets easily? multi-threading or am i dreaming?

You can use Codename One whose web port is based on TeaVM. The API is very much like Swing. Albeit more focused on mobile.

Re: New Java to WASM GC Transpiler: Run Java in the Browser, No Plugin Required

#15
post #5

Love the concept but no clear idea of a use case. Could you list 3 or 4 of them please?

JS frontend enthusiasts rationalized JS on the backend. Now Java backend enthusiasts can once again rationalize Java on the frontend. I would consider this for a project where I already have Java code on the backend and rewriting it for the front end in JS is a bigger barrier than adding TeaVM to the stack.

I'm actually in the process of converting my own little JS framework to Java using TeaVM. It's interesting and fun

Re: New Java to WASM GC Transpiler: Run Java in the Browser, No Plugin Required

#16
post #5

Love the concept but no clear idea of a use case. Could you list 3 or 4 of them please?

TeaVM author here. Personally I use it to bring a large (500KLOC) project that's written in Java and Kotlin to the browser (also we are using Graal VM Native Image to compile the same app to iOS, and Android supports). It's virtually impossible to maintain another 500KLOC code base on TS and on Swift and make sure that they behave and look 100% same. So the target audience is any team that wants to write in Java and/or Kotlin applications that works in JVM as well as in the browser.

Re: New Java to WASM GC Transpiler: Run Java in the Browser, No Plugin Required

#17
post #6

I am more enthusiastic with Kotlin also compiling to wasm with Jetpack compose and now working in all major browsers. It provides a full modern UI framework and also compiles to mobile and desktop. Code is also usable on server and if using the JVM fully interoperable with Java.

TeaVM supports Kotlin as well. The difference with Kotlin/Wasm is that with Kotlin/Wasm you are limited only to Kotlin and can't use any code written in Java.

Re: New Java to WASM GC Transpiler: Run Java in the Browser, No Plugin Required

#18
post #5

Love the concept but no clear idea of a use case. Could you list 3 or 4 of them please?

* Grab A, some software that can be compiled to Java bytecode [1].

* Grab B, some software that can run wasm [2].

* Run A on B.

Just one example, since this "algorithm" can generate endless combinations! You could create some game logic in Kotlin, Clojure or Scala, compile it to WASM, and run it on Taca [3] (a runtime for multimedia wasm apps that runs native and in browsers).

--

1: from TeaVM front page: "the source code is not required to be Java, so TeaVM successfully compiles Kotlin and Scala"

2: There are many projects out there embedding some WASM runtime, not just browsers.

3: https://github.com/contextfreeinfo/taca

Re: New Java to WASM GC Transpiler: Run Java in the Browser, No Plugin Required

#19
post #5

Love the concept but no clear idea of a use case. Could you list 3 or 4 of them please?

If OpenAI some day wants to add support for languages like Clojure, Scala, etc, they could use this.

(For the Python version see https://simonwillison.net/2024/Dec/10/chatgpt-canvas/)

Re: New Java to WASM GC Transpiler: Run Java in the Browser, No Plugin Required

#20
post #9

Love the revenge of plugins. We might have lost a decade since Unreal was running on Flash Crossbridge, yet thanks to Web trying to be a app platform to replace native apps, we are back full circle. Java, .NET have their plugins back, even if with additional turtles along the stack, and stuff like Flutter are the new Flash. I guess, thanks to all WebGL, WebGPU and WebAssembly folks

Java plugins were mainly useful to do naughty things (for instance in a previous life I used a Java plugin to load and call into a native DLL via JNI which spawned a Win32/D3D9 game client inside a browser by attaching as a child window of the Java plugin canvas). Fun stuff but not really a good idea from a security point of view ;)

And of course this cannot be replicated with a Java plugin running in a (browser) WASM engine.

Post reply on HN