r/java • u/alexp_lt • Apr 21 '26
CheerpJ 4.3 - Run unmodified Java applications in the browser
https://labs.leaningtech.com/blog/cheerpj-4.3
84
Upvotes
r/java • u/alexp_lt • Apr 21 '26
View all comments
Show parent comment
4
u/pron98 Apr 21 '26
I've been working on compilers in some form or another for a couple of decades and I've never quite understood what a "transpiler" is (it doesn't seem to be a well-defined term or one that's used consistently, and it's not commonly used in the compiler space), but in any event, TeaVM is not a source-to-source compiler. Rather, it's a Java bytecode to JavaScript compiler.
From what I can tell, the architectural difference between CheerpJ and TeaVM is that TeaVM compiles Java bytecode to JS ahead-of-time, while CheerpJ includes a bytecode interpreter in WASM and a bytecode -> JS JIT compiler.
In practice, CheerpJ claims to be a JVM, i.e. a mechanism for running all Java classes in accordance with the spec, while TeaVM isn't, i.e. it doesn't necessarily run all Java classes in accordance with the spec (there's nothing inherent to the JVM spec that requires either an AOT or an interpreter + JIT approach).