| > So we are back at where WASM is? Exactly. By the time you've done all that, whats the point? You'll have reimplemented wasm on top of the jvm in a way that: - Can't use any of the java standard library (which all existing java code depends on) - So you also can't use any existing java code - You need a compilation step for any existing code in other languages to convert it into your special limited java syntax - And the result will run slower than wasm because of the extra layer of abstraction going on The one advantage is that you can output everything as standard .class files, so it'll be easier to pull this code into an existing java application. And yes, you could absolutely do that if you want and you see value in it. Heck - maybe it'd be nice to have a wasm-to-java-class converter to let you reuse all the wasm infrastructure. But this all sounds like the java equivalent to asmjs, which we already tried. Asmjs was the precursor to wasm. It was built on top of javascript primitives in much the same way as the proposal here builds on top of java primitives. As I understand it, the reason we ended up with wasm instead of asmjs was that: - Wasm was easier to optimize, had a smaller file size and was faster to load at runtime (since you don't need a javascript compiler) - Its much easier to make VMs for wasm in lots of languages and environments. Wasm modules can be loaded into programs written in python, rust, C, java, go, javascript, etc without some weird unnecessary dependency on javascript. |
One can surely cherry-pick quite a lot out of it that are safe to use, e.g. anything not using `native` implementation can as per the former definition of JVM interpreter, also end up being safe. So many existing code would run without any change.
> Re: compilation step
Why? It has nothing to do with Java, the language, only the JVM class file format. Scala/Kotlin produce bytecode directly, not Java code.
> Run slower
Why would it? Wasm can run fast having grown out from asm.js, yet a JITted runtime that runs half of the internet can't?
> Its much easier to make VMs for wasm in lots of languages and environments
There are plenty toy JVMs out there as well, the core really is not difficult.
And the point of all this would be that large chunks of the JVM could have been reused, that runs on every platform with top notch performance already, without all the growing pains that WASM will experience. Also, the JVM's type safe cross-language capabilities are already here, while they are very experimental and rudimentary in case of WASM. I can just call a Kotlin class from Clojure, or JPython or whatever, and vice versa.