HACKER Q&A
📣 theanonymousone

TeaVM or GWT?


Well not much beyond the title. For someone who wants to write a client-side web application in Java for whatever reason, which option is better in 2023? Better means more modern and more maintainable in the future (e.g. support latest Java versions). Thanks


  👤 konsoletyper Accepted Answer ✓
As an author TeaVM I can tell you about advantages of TeaVM compared to GWT.

1. TeaVM can compile not only Java, but Scala and Kotlin. Actually, any JVM language, which is not using much reflection, invokedynamics and dynamic class loading in its runtime. It's possible because TeaVM uses JVM bytecode, not Java source code, as an input. 2. TeaVM can emulate threads. TeaVM won't spawn real threads, it will turn Java methods into coroutines and schedule their execution upon one physical thread. This won't speed-up programs by using multiple cores, but for example you can use Java synchronous IO APIs in a background thread. 3. TeaVM has more advanced reflection support. You can list class' methods and fields, call methods and get/set field via reflection (but as in any other AOT compiler you should list reflectable methods and fields). 4. Maven and Gradle plugins both available out-of-the-box, you don't need any 3rd party tool. 5. I usually get positive feedback from my users about compilation time compared to GWT. 6. TeaVM already has some limited support of compilation to WebAssembly.

As for latest Java version, TeaVM currently supports Java 21.


👤 gjvc
for the future, WASM would be a better bet than either of these two.