• A Cartoon intro to WebAssembly
  • Originally written by Lin Clark
  • The Nuggets translation Project
  • Translator: Square root of three
  • Proofreader: Reid, Tina92

WebAssembly runs fast, as you’ve probably heard. But what makes WebAssembly so fast?

In this series of articles, I want to explain to you why WebAssembly is so fast.

Wait, what exactly is WebAssembly?

A WebAssembly is a way of writing code in a programming language other than JavaScript and running that code in a browser. So when people say WebAssembly runs fast, they’re usually comparing it to JavaScript.

Now, I don’t want to imply that this is a binary situation — you can either use WebAssembly or you can use JavaScript. In fact, we expect developers to be able to use both WebAssembly and JavaScript in the same application.

But it’s useful to compare the two so you can understand the potential impact WebAssembly will have.

A bit of performance history

JavaScript was created in 1995. It wasn’t designed to be fast, and for the first decade, it wasn’t.

Then the competition between browsers began to get more intense.

In 2008, the so-called “performance wars” era began. Many browsers have added a just-in-time compiler, also known as a JIT. When JavaScript is running, the JIT can see patterns and make the code run faster based on those patterns.

The introduction of these JIts led to a turning point in JavaScript performance. JS executes 10 times faster.

A graph showing JS execution performance increasing sharply in 2008

With this performance improvement, JavaScript began to be used for things that no one expected it to do. For example, node.js is used for server-side programming. Performance improvements make it possible to use JavaScript for a whole new set of problems.

With WebAssembly, we may now be at another inflection point.

A graph showing another performance spike in 2017 with a question mark next to it

So let’s dive into the details to understand what makes WebAssembly so fast.

Chapter two: Portals