WebAssembly is fast. You’ve probably heard this. But what is it that makes WebAssembly fast?
In this series, I want to explain to you why WebAssembly is fast.
Wait, so what is WebAssembly?
WebAssembly is a way of taking code written in programming languages other than JavaScript and running that code in the browser. So when people say that WebAssembly is fast, what they are comparing it to is JavaScript.
Now, I don’t want to imply that it’s an either/or situation — that you’re either using WebAssembly or using JavaScript. In fact, we expect that developers will use both WebAssembly and JavaScript in the same application.
But it is useful to compare the two, so you can understand the potential impact that WebAssembly will have.
A little performance history
JavaScript was created in 1995. It wasn’t designed to be fast, and for the first decade, it wasn’t fast.
Then the browsers started getting more competitive.
In 2008, a period that people call the performance wars began. Multiple browsers added just-in-time compilers, also called JITs. As JavaScript was running, the JIT could see patterns and make the code run faster based on those patterns.
The introduction of these JITs led to an inflection point in the performance of JavaScript. Execution of JS was 10x faster.
With this improved performance, JavaScript started being used for things no one ever expected it to be used for, like server-side programming with Node.js. The performance improvement made it feasible to use JavaScript on a whole new class of problems.
We may be at another one of those inflection points now, with WebAssembly.
So, let’s dive into the details to understand what makes WebAssembly fast.
Background:
WebAssembly, the present:
WebAssembly, the future:
About Lin Clark
Lin works in Advanced Development at Mozilla, with a focus on Rust and WebAssembly.
22 comments