What is WebAssembly?
The Dawn of a New Era
The future of the web platform looks brighter than ever.
Google, Microsoft, Mozilla, and a few other people have been secretly toiling away in a new W3C WebAssembly Community Group, and what they have been working on is no small thing.
For more depth, see the follow-up article, “Why We Need WebAssembly: An Interview with Brendan Eich”.
- A new language: WebAssembly code defines an AST (Abstract Syntax Tree) represented in a binary format. You can author and debug in a text format so it’s readable.
- A Compile Target: A way for other languages to get first-class binary support across the entire web platform stack.
Before we answer this question, let’s back up a moment. Let me take you back in time… back… back…, back before React, before Angular, before Backbone, before jQuery…
Ah, here we are.
The web is a scattering of hypertext documents on bulletin board systems, not yet interlinked. The first web server is being hacked together on a NeXT workstation at CERN…
The year is 1991 and my hair isn’t gray yet. I’m hacking together my ten thousandth text adventure game (something like that, I’m not counting).
I made a peculiar language choice for this one. I was sick of working in BASIC and Pascal. I wanted to use C, but I was still saving up for my first Borland Turbo C++ boxed set (they literally came in boxes packed with manuals and install disks). I didn’t even have Turbo Assembler, yet.
I was writing in assembly language and “compiling” to an executable with the DOS `debug` command line tool. If that sounds crazy, believe me, it was. I’m betting even those of you who used DOS probably didn’t realize you could use debug to assemble instructions, as well as disassemble (reverse engineer) existing code.
Sound cool? I hated it. I couldn’t wait to get my hands on Borland Turbo C++ so I could write code like a human being. Eventually, I got it as a gift. Score!
But one of my favorite things about Borland Turbo C++ was that it came bundled with Borland Turbo Assembler. What?! Why would you want to write code in assembly language when you have a great high-level object-oriented language like C++ in your toolbelt?
Sometimes you want to get to the bare metal, or as close to it as you can get without melting your brain. Did I mention that I also wrote a lot of machine language prior to getting my hands on C++?
I lost my mind.
It’s much harder to get real work done when you’re writing directly in assembly language. So why do we need this WebAssembly thing?
WebAssembly gives us access to a set of low level building blocks that we can use to construct just about anything you can imagine.
These are very simple primitives. Nothing fancy. No complicated object system (prototypal or otherwise). No built-in automatic garbage collector following you around and stopping you periodically while it cleans up your scraps.
What Exactly is WebAssembly?
WebAssembly defines an Abstract Syntax Tree (AST) that gets stored in a binary format. Binary is great because it means we can create smaller app bundles. You’re probably wondering how we’ll debug a binary language format.
What will WebAssembly be used for?
Among other things, it will be easy to express things like threads and SIMD — a fancy word that means you can line up multiple chunks of data next to each other and invoke a single instruction to operate on all of them at the same time. It stands for Single Instruction, Multiple Data.
This is one of those cases where you’ll probably want to forget about the object system, the garbage collector, and all the fancy dynamic stuff. Just line up some raw bits in little rows and crunch through them as fast as possible.
Show me the Apps
Games, VR and augmented reality are the obvious examples. Most of the current WebAssembly demos use Unity or Unreal Engine, both of which already support compiling to asm.js. Right now, music production apps like Ableton Live and video production apps like Adobe Premier Pro are still a bit awkward to port to the web. Not impossible, mind you, just awkward. There are still lots of problems to solve, like better timing guarantees for data intensive realtime apps.
WebAssembly fills in the gaps
that would be awkward to fill
But what some of us have really been missing is the ability to write most of the code in an amazing high-level language and still be able to drop down to a specialized, bare metal assembly language once in a while when we really need a boost.
I’m sure there are 200 other articles on WebAssembly being published today all over the web. I’ll bet most of them will focus on the other side of WebAssembly, which I’m equally excited about…
WebAssembly Brings Language Diversity to the Web Platform
In case you’ve heard
WebAssembly gives us an alternative compile target — One specifically designed for that purpose.
As great as it is to hear that all the old languages we know and love will run on the web platform now, WebAssembly means one more very important thing:
WebAssembly is an open invitation
to developers building
future programming languages.
The future of the web platform has never looked brighter. You’d better pull out your shades.
Update / FAQ
Short for WebAssembly.
Why not use the JVM?
Q: Doesn’t this mean other languages will take over? Won’t this cause fragmentation?
What are the Text Formats Like?
The most popular is a lisp-like S-expression form. For a taste, check out the WebAssembly Playground.
Where Can I Learn More?
See the follow-up article, “Why We Need WebAssembly: An Interview with Brendan Eich”.
2015 LLVM Developers Meeting talk by JF Bastien and Dan Gohman
How can I stay in the loop?
Eric Elliott is a tech product and platform advisor, author of “Composing Software”, cofounder of EricElliottJS.com and DevAnywhere.io, and dev team mentor. He has contributed to software experiences for Adobe Systems, Zumba Fitness, The Wall Street Journal, ESPN, BBC, and top recording artists including Usher, Frank Ocean, Metallica, and many more.
He enjoys a remote lifestyle with the most beautiful woman in the world.