WebAssembly has been gaining popularity in recent times. It's fast, it's "hip" and my God, C/C++ and Rust developers seem to mention it a lot these days. There are several articles already written for Wasm (as I'll keep calling WebAssembly in this article). Go here for my article on using WebAssembly, Go and React. There is also a Rust port here. The Rust port is up and running at this URL.
Java is a language that needs no introduction. The JVM is simply a virtual machine that takes in Java bytecode and then spit out the machine code of the CPU the code is running on. That way, you can write any language that is supported by the JVM (e.g Scala) and run it on any CPU/platform. This forms the basis of Java's Write Once, Run Anywehere. Enter Wasm.
Wasm basically is a format that allows you compile code you've written in various languages on any hardware/platform in a safe environment.
So how does Wasm differ from the JVM?
- Wasm is platform-agnostic. You can run it as a VM, you can embed it as a library, inside other environments like the browser engine. While Java itself is platform agnostic, the JVM isn't.
- Speed. Wasm runs at near native speed.
- Security. WebAssembly lets you run code you don't trust. It runs in its own sandbox.
- In the frontend, there are JS bindings from your host language. This means you can write your app in a language like Rust. You can manipulate the DOM directly, compile to Wasm and have JS bindings generated for you.
Personally, my biggest takeaway from the differences between JVM and WebAssembly is that the JVM is platform-dependent and less secure while Wasm is platform-independent and provides near native speed for whatever architecture you're running on. I think its pretty obvious that Wasm is not just another JVM. WebAssembly is WebAssembly