Live data from Hacker News

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

teavm.org

31–40 of 59 posts

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

#32
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.

Aren't ppl like that are more likely to use vaadin and similar frameworks?

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

#33
A little over 10 years ago, I ran across TeaVM for the first time (probably) on GitHub. We had been looking for a way to port Codename One to the web, but we needed thread support, which wasn't supported by any existing solutions.

I emailed Alexey (the creator of TeaVM) to ask if he had plans for thread support, and he replied that, while "proper" threads weren't possible, he had some ideas for supporting green threads. Over the following 6 months or so, Alexey would share updates on progress he had made on the thread front. In March 2015, he shared that he had found a new approach for async code that wouldn't affect the performance of single-threaded code, and would support natural stack traces. We released a preview of our web port using TeaVM a month later, and it exceeded all of our expectations, both in how easy it ended up being to do the port (because of TeaVM), and on the performance.

Alexey's solution for supporting threads, was truly a piece of genius. Had he not created TeaVM, and added threading support, I don't think we would have ended up with our web port - or, at the very least it wouldn't have ended up performing nearly as well.

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

#34
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?

I think Swing is a non-goal of this project. It provides good interop with the DOM and core JS methods, and it makes it easy to create your own interop for JS apis that aren't in the core.

There are at least two GUI toolkits that run on TeaVM: 1. Codename One. Similar to swing, but focused on mobile https://www.codenameone.com 2. SnapKit. Targeted at desktop. Also a light-weight toolkit, like Swing. https://github.com/reportmill/SnapKit

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

#35
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

Really? Has Flutter turned into the new Flash?

Looks like heading into that direction.

https://rive.app/

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

#36
post #8

Earlier quoted context omitted.

Try calling Kotlin co-routines from Java, fully interoperable is it not. Additionally I really dislike the anti-Java discourse in Kotlin circles, as if Kotlin was able to stand on its own, without the Java ecosystem, or Google's making it Java replacement on Android.

I didn’t get a sense of anti-java-ism from the parent poster. While I enjoy Kotlin more than Java I see the benefits of both, and from most folks I’ve spoken to about the two they seem fairly level-headed about the situation. I think that for all language discussion online that there is a very small percentage of people that get over-inundated by the emotional feeling of “investing their time” into a language and wan…

I didn't target the parent poster, rather the community in general.

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

#37
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) WAS…

All code can be abused for naughty things, including crypto miners in modern Web APIs.

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

#38
post #35

Earlier quoted context omitted.

Really? Has Flutter turned into the new Flash?

Looks like heading into that direction. https://rive.app/

Oh I interpreted it as the way Flash got extinct, not which role it played on the web. That makes sense.

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

#39

Does it support JavaFX applications aswell, that would be very cool? Last time I had to recreate a project in Flutter.

No TeaVM doesn't do Swing or JavaFX. But WebFX does: https://webfx.dev/ Gluon also has a cool JavaFX in the browser demo but I think it's dead: https://gluonhq.com/developer-preview-for-javafx-inside-a-we...

Webfx looks like something I could use, thanks!

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

#40
post #5

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

Here are over a dozen TeaVM-based projects, for inspiration: https://www.frequal.com/TeaVM/TeaVmBasedSites.html

Several use cases where TeaVM shines:

* A developer or team has strong Java skills and wants to develop single-page apps

* A Java desktop project wants to move to the web and has lots of validation logic they don't want to double-maintain in Java and ECMAScript/WASM

* A Java-based game developer wants to make a Canvas-based version of their game for the web (potentially full-screen)

* A Java developer wants a batteries-included framework for web development. TeaVM comes with a minifier, tree-shaker, packager, and more, out of the box, with familiar 'mvn clean install' semantics (And Gradle support too).

For more details on use cases and reasons for picking TeaVM, read chapter 1 of my book here: https://frequal.com/Flavour/book.html

Post reply on HN