In 2015, Mozilla announced that they were working with Chromium, Edge and Webkit to create a new standard called WebAssembly.
Why a new standard? Performance was a key motivation:
Overall, there are plenty of things to like about all this:
- The binary format will allow it be smaller over the wire, thus reducing time for the network request.
- The fact that it’s compiled will save the browser time upfront since it will not need to parse it.
- The human-editable text format will allow developers to write, view, and debug the code by hand.
- Programs written in other languages (C, C++, Rust, etc.) can target the web by being compiled to WebAssembly.
- And, there’s buy-in and involvement from all the major browser groups. It’s already shipped in Edge, Firefox, Safari (including iOS Safari), and has over 74% support globally.
Since there are performance benefits to be gained, and plenty of support for this new standard, when does it make sense to use WebAssembly?
Video games are a prime example where WebAssembly could be, and is already becoming, extremely useful. Virtual reality and augmented reality are also clear use cases, as are audio and video streaming and editing. In many of these cases, there are already codebases written in other languages that could compile to WebAssembly, and thus bring native performance to the web.
Although it’s possible to write WebAssembly by hand, it’s unlikely that this will be done much on larger codebases. Rather, the goal with the standard was to provide a compilation target, allowing other languages access to the web platform.
There are several things I like about what I’m seeing. In addition to the performance gains, I was especially pleased to see 1) the human readable text format as part of the standard; and 2) the effort to integrate as well as possible into the existing web platform.
As a web developer, the ability to View Source has been extraordinarily helpful over the years, and one of the things I like about the web. Knowing that WebAssembly is opening up the web as a target for more languages, but doing so in an open way that still allows developers to look under the hood, is great.
If you’re interested in learning more, here are some places you can start:
WebAssembly on MDN – As typical, the MDN web docs provide plenty of useful guides and reference material.
Awesome Wasm – An extensive list of resources, and other things, related to WebAssembly.