It’s much like GWT, however GWT takes source code, and this limits GWT to Java only.
Unlike GWT, TeaVM relies on existing compilers, be it javac, kotlinc or scalac.
These compilers produce bytecode (
TeaVM is for you, if:
- You are a Java developer and you are going to write web front-end from scratch.
- You already have Java-based backend and want to integrate front-end code tightly into your existing development infrastructure.
- You have some Java back-end code you want to reuse in front-end.
- You are ready to rewrite your code to work with TeaVM.
If you have bloated applications that use Swing, you want to run these applications in web, and you don’t care about download size, start-up time and performance, you better give up; there are more appropriate tools for you, like CheerpJ.
- TeaVM has a very sophisticated optimizer, which knows a lot about your code. Some examples are:
- Devirtualization turns virtual calls into static function calls, which makes code faster.
- TeaVM can reuse one local variables to store several local variables.
- TeaVM renames methods to as short forms as possible; UglifyJS usually can’t perform such optimization.
- TeaVM is very fast, you don’t need to wait for minutes until application gets recompiled.
- TeaVM produces source maps; TeaVM IDEA plugin allows to debug code right from the IDE.
Another purpose of Flavour is: due to several reasons it’s hard to support entire JDK in TeaVM, especially things like reflection, class loading, resources, threads, thus most Java libraries for data serialization and network communication are unavailable in TeaVM. Flavour reimplements reasonable subsets of Jackson and JAX-RS client without a single line of reflection.
Flavour is not a server-side framework. You are supposed to write your back-end code using “normal” JDK like OpenJDK, Oracle JDK using your favourite framework like Spring, Java EE, Vert.x, etc. Flavour is a client-side framework that you can use together with your back-end code. To make this easier, Flavour tries to be as close to usual Java developers as possible.
Why using TeaVM while there are plenty of transpilers and frameworks for web front-end development?
TeaVM allows you to use single ecosystem, and reuse as much as possible of it for both back-end and front-end worlds.