What is WebAssembly (Wasm)?
A (hopefully) easy read on a tough subject
So, what is it?
Very simply, it’s a standard for generating language-agnostic computer programs that are optimized for running in a web browser.
A better high-level description of Wasm can be found in the “high level goals” section of the Wasm docs.
In particular, I find the following two passages very informative:
- “a portable, size- and load-time-efficient binary format to serve as a compilation target which can be compiled to execute at native speed by taking advantage of common hardware capabilities available on a wide range of platforms, including mobile and IoT.”
- “[Designed] to execute within and integrate well with the existing Web Platform”
Let’s unpack those a little.
WebAssembly is “portable” because it can run on a variety of different operating systems and architectures. This is thanks to WebAssembly compilers which produce machine code from Wasm code. Wasm compilers can vary in implementation, but the ones to worry about for now are the ones implemented for use in major browsers.
Higher level languages can be compiled into WebAssembly in a process also known as “transpiling” or “transcompiling”. Have Ruby? Compile it to WebAssembly! Have Rust? Compile it to WebAssembly! However, as of this moment the focus is on supporting C/C++.
Once we’ve got our WebAssembly, we take the final step and compile the WebAssembly into machine code and execute it. Now we have a program that runs natively, whether that be on your laptop, mobile device, or refrigerator!
“[Designed] to execute within and integrate well with the existing Web Platform”
What are the implications?
Since the end of 2017, WebAssembly has been supported in Chrome, FireFox, Safari, and Edge. Although far from finished, it is slowly marching toward the mainstream. When that arrives, what will happen?
No idea really!
Stuff will be faster. The performance of Wasm enables more computationally intensive programs like 3D games. Give Tanks! a whirl.
One thing that we can be pretty certain of is that it will make the web a better place. It will be faster, more accessible, and enable further innovation. Hoorah!
Thanks for reading! Want to work on a mission-driven team that loves technology and the web? We’re hiring!