Mozilla tries to do Java as it should have been – with a WASI spec for all devices, computers, operating systems
One binary to rule them all
Mozilla this week announced a project called WASI (WebAssembly System Interface) to standardize how WebAssembly code interacts with operating systems. If the project succeeds, it will do what Oracle's Java Virtual Machine does, but better and more broadly.
WebAssembly, or WASM, is a binary format for a virtual machine that can run across multiple hardware architectures. WASM code can be produced from various programming languages like C/C++, Go, and Rust as a compilation target.
WebAssembly has been adopted by all the major web browsers, but it doesn't yet have a standard way to run outside the browser. That's where WASI comes in.
"Code outside of a browser needs a way to talk to the system – a system interface," explains Mozilla software engineer Lin Clark in a blog post. "And the WebAssembly platform doesn’t have that yet."
What's up with WASM?
With WASI, WASM code will be able run in the browser or any compliant environment, allowing language agnostic, cross-platform application deployment. Where Portable Operating System Interface (POSIX) provides a way to make source code portable across Unix-like operating systems, WASI aims to make compiled binaries portable across devices and operating systems. It promises a universal runtime that runs at near-native speed.
The Java Virtual Machine (JVM) serves the same purpose but you can't run Java code in a browser without a plugin. And while the language flexibility offered by the WebAssembly platform may be achievable in Java via the GraalVM, the Java ecosystem, open though it may be, still stands in the shadow of Oracle and its claims on Java-related IP.
WASM, being memory safe and tuned for validation, also has security advantages over Java applets, though it still may be vulnerable to control flow hijacking. It also plays nicer with languages like C/C++ and Rust.
Till Schneidereit, who manages Mozilla's WebAssembly team, via Twitter, explained the difference between WebAssembly and Java thus: "WebAssembly has been designed to scale from tiny devices to large server farms or CDNs; is much more language-agnostic than Java; and has a much smaller implementation footprint."
Aw, all grown up: Mozilla moves WebAssembly into sparsely furnished Studio apartmentREAD MORE
If the potential significance of WASI isn't yet apparent, consider how it's characterized by Solomon Hykes, who co-founded Docker. "If WASM+WASI existed in 2008, we wouldn't have needed to created Docker," he said. "That's how important it is. WebAssembly on the server is the future of computing. A standardized system interface was the missing link. Let's hope WASI is up to the task!"
Riding this wave of optimism, CDN biz Fastly on Thursday released Lucet, its native WebAssembly compiler and runtime for running WASM code in an edge cloud environment. It complements Mozilla's Wasmtime, a runtime for running WASM code outside the browser.
There's much work still to be done before WASI is fully baked. WebAssembly too could bear further refinement, like the ability to access to the browser's DOM (Document Object Model). But a write-once, run anywhere binary represents a worthwhile effort. In the meantime, enjoy your Java. ®
Sponsored: Becoming a Pragmatic Security Leader