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.

a portable,”

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.

size- and load-time-efficient binary format

The Wasm binary encoding lets Wasm code exist in a form that optimizes for space. One major benefit of shrinking down Wasm code is that it reduces the amount of time it takes to send it over a network, a common bottleneck in network-oriented programming problems such as web application development. This is in contrast to JavaScript, in which a program’s minimal representation is limited to encodings like ASCII or UTF-8.

to serve as a compilation target

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++.

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.

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”

This includes benefits like compatibility with JavaScript, access to Web APIs like the DOM’s, and all the security guarantees that come with browsers.

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.

The barrier to writing programs for the browser in different languages will be lessened. Is Wasm trying to replace JavaScript? The creators explicitly say no and Brendan Eich makes some very compelling points in this interview as to why it just won’t happen. However, maybe more people will start writing applications in languages like Dart or Elm once they can leverage the benefits of Wasm.

Here’s a list from the Wasm docs on more possible Wasm use cases.

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!


Footer top

To learn more about Flatiron School, visit the website, follow us on Facebook and Twitter, and visit us at upcoming events near you.

Flatiron School is a proud member of the WeWork family. Check out our sister technology blogs WeWork Technology and Making Meetup.

Footer bottom