WebAssembly: The Next Language of the Web
At Hashrocket's Winter Miniconf 2020, I presented a summary of my personal one-month audit of WebAssembly. Here's what I learned.
A New Web
- A high-level language
- JIT (just-in-time) compiled
- Object-oriented, with prototypical inheritance
- Curly-bracketed, dynamically typed, has first-class functions, etc.
Now picture another web. A web where you can write in your favorite languages, such as Elixir, Ruby, Python, and lower-level languages like C/C++, Rust, Go. You'd write code once in your language of choice, and share it across server and client. You even could even write code in the same language that your browser is written in. The code would run on the client with near-native performance.
Some people consider this the Holy Grail of the Web. And if you believe the hype, it is already here, in the form of a language called WebAssembly.
What is WebAssembly?
"WebAssembly, or wasm, is the most significant new technology to come to the web platform in a decade." --Mozilla.org
I think WebAssembly is at least two things:
- A new type of code
- A standard
Let's explore each.
A New Type of Code
WebAssembly is a low-level Assembly-like language with a compact binary format. It provides other languages with a compilation target so they can run on the web. You may be familiar with Assembly: it's a low-level programming language where the instructions closely match the machine code. Some call Assembly "symbolic machine code", so think of this new tool as bringing that machine code into the browser. It's a mashup of technologies.
That's why everyone is treating it like such a big deal; this shared ownership suggests WebAssembly might actually cross the chasm of adoption. Furthermore, being a standard means that, like JS, CSS, or HTML, WebAssembly is a foundation upon which we can build. There isn't a Benevolent-Dictator-for-Life or core team determining its direction. Instead, a committee of practitioners, academics, and businesspeople have their hands in the construction process.
How Might WebAssembly Change the Web?
I think this tool is going to affect our workforce as developers, the performance of our apps, and our experience as web consumers.
Our experience as consumers will also change. Imagine gaming in the browser with the performance of a console or desktop; that is coming. Performance gains are likely to translate into more content as online games become bigger, faster, and better.
Yes, WebAssembly lacks some core features such as DOM manipulation and garbage collection that people expect of a modern language. However, most of those missing features can be found in the WebAssembly development roadmap.
I believe that WebAssembly is going to dramatically change the web. I'm excited by the potential it represents. What could you build with it? Let me know on Twitter. In closing, here's a list of resources I collected while learning about WebAssembly:
- A cartoon intro to WebAssembly
- Awesome WebAssembly Languages
- Developer's Guide
- Emscripten & asm.js
- Introduction to WebAssembly
- Made with WebAssembly
- Oh the things you'll compile
- Rust: Wasm
- Wasm by Example
- WebAssembly Weekly
- WebAssembly as a Platform for Abstraction
- WebAssembly becomes a W3C Recommendation
- WebAssembly format
- WebAssembly docs
- WebAssembly: A game changer for the Web | Mozilla
- What are disadvantages of WebAssembly compared to current HTML/JS?
- World of WebAssembly!
- Official site
Thanks for reading.
Photo by Umberto on Unsplash