Stream: general

Topic: whats the difference between wasmtime and the JRE/JDK?


view this post on Zulip Srayan Jana (Oct 12 2024 at 18:20):

From what I understand, WASM is basically the same idea (ish) as the JRE/JDK, a virtual machine that multiple languages can compile down to and talk to each other. What then, are the main differences?

view this post on Zulip Lann Martin (Oct 12 2024 at 18:58):

There are many kinds of differences, but from a practical standpoint the two biggest are probably language support and browser support.

view this post on Zulip bjorn3 (Oct 12 2024 at 18:58):

The Java VM doesn't support C like languages that don't use a GC, while wasm initially only supported those languages well. It has GC support too since recently, but using it is not mandatory the way it is with the Java VM. Java has also given up on attempting to support sandboxing, while wasm has a big focus on sandboxing as that is needed for safe usage of wasm in the browser.

view this post on Zulip Chris Fallin (Oct 12 2024 at 23:03):

in addition to linear memory vs. GC object model, there are significant differences in the complexity of the underlying VM. The JVM has a class loader mechanism, virtual method dispatch, interfaces, and all of that baked into the VM; the idea was to build a VM close to the semantic level of the source language. Wasm on the other hand has memory load/store and indirect call, and expects the guest to build everything from those; the idea was to build a VM close to the semantic level of machine code. (The one key departure is in first-class functions / a "protected stack", as @Dan Gohman likes to say, which has a bunch of implications for things like coroutines and exceptions.) The key corollaries from that are:

view this post on Zulip Chris Fallin (Oct 12 2024 at 23:06):

One more thing that actually has real value: the spec is tiny, and has a formal semantics; from this, we have formally verified interpreters and semantics we can use in other places to do formal verification. This has actually been used in practice to prove pieces of Wasm implementations correct, and the formally verified interpreter is used as a differential fuzz oracle.


Last updated: Dec 23 2024 at 13:07 UTC