November 19, 2020—Is it for the web? Is it assembly?
Here’s what WebAssembly has to say about itself:
WebAssembly (abbreviated Wasm) is a binary instruction format for a stack-based virtual machine. Wasm is designed as a portable compilation target for programming languages, enabling deployment on the web for client and server applications.
I’ve been learning WASM recently. I think I’m coming out of the Trough of Disillusionment. Let me explain why.
First, you need to understand that it isn’t limited to just the internet:
While WebAssembly is designed to run on the Web, it is also desirable for it to be able to execute well in other environments, including everything from minimal shells for testing to full-blown application environments e.g. on servers in datacenters, on IoT devices, or mobile/desktop apps. It may even be desirable to execute WebAssembly embedded within larger programs.
And right now you can compile/convert all these languages and more into WASM:
WASM is pretty flexible. It has provisions for interacting with the host environment but it isn’t overly opinionated about it. There’s a way to call host-provided functions (called “imports”). This has enabled the WebAssembly System Interface (WASI) spec, which is basically a pared-down set of POSIX functions.
Solomon Hykes, the co-founder of Docker, said this about WASM+WASI:
If WASM+WASI existed in 2008, we wouldn’t have needed to created (sic) Docker. 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!
Let me say that again: WASM (plus a spec for some imported functions) can do everything that Docker does.
These are all Good Things™. These kinds of things make me very excited as a programmer.
But something fishy is going on. Because it’s called Web Assembly.
What do all of these big-name organizations have in common? The internet.
Now to be fair those aren’t the only organizations involved. But…
There is interest in expanding support so that more languages can be compiled to WASM, but it’s clear the goal is always to get those languages to run in a browser.
So which is it? Is it for the web or not?
Why don’t they just save garbage collection and reference graphs for a layer built on top of WASM? Because they want GC languages to be able to run in today’s internet browsers with minimal delay.
I don’t know of a single assembly language that:
Now I might be wrong. There might be other “assembly” languages with those things. But those things certainly don’t sound like “common hardware capabilities”.
WebAssembly aims to execute at native speed by taking advantage of common hardware capabilities available on a wide range of platforms.
So why did they both plan those things and call it Web Assembly?
Coming out of the Trough of Disillusionment implies I’ve crested the Peak of Inflated Expectations. So what was I expecting?
I was expecting the One Language to Rule Them All. I was expecting a universal assembly language.
WASM just isn’t what I was hoping for.
Is it good for running programs in today’s internet browsers? Sure. But I think it is being influenced too much by today’s internet technologies. And we all know how fast the internet changes.
So I’d stick to the web for WebAssembly.