konsoletyper | 1 year ago | on: New Java to WASM GC Transpiler: Run Java in the Browser, No Plugin Required
konsoletyper's comments
konsoletyper | 1 year ago | on: New Java to WASM GC Transpiler: Run Java in the Browser, No Plugin Required
konsoletyper | 2 years ago | on: Missing the Point of WebAssembly
And according to my experience, WebAssembly is not a game changer: it does not provide extra performance here, neither does it allow to get smaller binaries. I'm a developer of another Java-to-JavaScript compiler, TeaVM. I recently compared performance of JavaScript and WebAssembly targets, and in one particular case WebAssembly is slower: https://teavm.hashnode.dev/comparing-teavm-with-kotlinjs-pef.... There's another example where WebAssembly is only slighly better: https://teavm.org/gallery/jbox2d/index.html. In both cases WebAssembly binary is huge compared to JavaScript. On one hand this can be because of I don't target Wasm GC, so binaries get bloated because of need to maintain shadow stack. On another hand, there's Google Closure Compiler, which produces Wasm GC binaries, and from what I heard of it, WebAssembly binaries still don't win in their size.
konsoletyper | 2 years ago | on: Spin 2.0 – open-source tool for building and running WASM apps
konsoletyper | 2 years ago | on: Ask HN: TeaVM or 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.
konsoletyper | 3 years ago | on: Cheerp 3.0: C++ compiler for the Web, now permissively licensed
Sorry, but what exactly were you expecting? I would improve documentation, but to me it looks ok. What sort of example you need? What's wrong with the Hello World link you posted, i.e. https://github.com/konsoletyper/teavm/tree/master/samples/he... ?
konsoletyper | 3 years ago | on: Cheerp 3.0: C++ compiler for the Web, now permissively licensed
konsoletyper | 5 years ago | on: TeaVM: Build Fast, Modern Web Apps in Java
konsoletyper | 5 years ago | on: TeaVM: Build Fast, Modern Web Apps in Java
These thoughts made me quit my job at Kotlin team and join Delightex to work on their product that uses TeaVM heavily: https://edu.cospaces.io/
konsoletyper | 5 years ago | on: TeaVM: Build Fast, Modern Web Apps in Java
konsoletyper | 6 years ago | on: Comparing JVM alternatives to JavaScript
konsoletyper | 7 years ago | on: Show HN: 300k lines of Java UI code running native in browser at desktop speed
* To make GC work properly you have to maintain GC roots. GC roots are static fields + variables in stack. There's no way in WASM to walk the stack! You have to maintain your own shadow stack, losing performance. In case of generating native code (e.g. x86/64) you can access native stack freely and finding GC roots produces no overhead (which is already done by JS engines).
* To make exceptions work properly, you need to walk the stack, and not only read it, but also write to it (in case of x86, update RSP direcly). This is not supported by WASM. But JS engines already do it natively, with no overhead for exceptions, until you throw then. With WASM you have to check after each call whether the exception was thrown or not, and that affects performance.
* In native environment you can do memory protection magic for different runtime things, e.g. to detect null pointer access, and that's not possible with WASM.
* In WASM you can't mutate code, so it makes impossible to implement lazy initialization logic without some overhead. JavaScript engines can detect that certain function got changed and de-optimize calling function, then optimize it again.
So, according to my experience and my benchmarks, compiling Java to JavaScript is a better option, both from performance and code size standpoint. WASM team is working on GC and exception handling, but they do it slowly and current design is far from perfect. I failed to convince them to just give access to stack, perhaps in some limited way (for security reasons).
And yes, the lack of access to stack even affects C code. For example:
int i = 23; foo(&i);
konsoletyper | 8 years ago | on: TeaVM – Ahead-of-time transpiler of Java bytecode to JavaScript or WebAssembly
konsoletyper | 8 years ago | on: TeaVM – Ahead-of-time transpiler of Java bytecode to JavaScript or WebAssembly
As for Java libraries, TeaVM is able to throw away unused parts of it, producing relatively small binaries.
konsoletyper | 8 years ago | on: TeaVM – Ahead-of-time transpiler of Java bytecode to JavaScript or WebAssembly
konsoletyper | 8 years ago | on: TeaVM – Ahead-of-time transpiler of Java bytecode to JavaScript or WebAssembly
konsoletyper | 8 years ago | on: TeaVM – Ahead-of-time transpiler of Java bytecode to JavaScript or WebAssembly
konsoletyper | 8 years ago | on: TeaVM – Ahead-of-time transpiler of Java bytecode to JavaScript or WebAssembly
And even more in 0.6.x (including Stream API)