This article is translated
A Cartoon intro to WebAssembly
Originally written by Lin Clark
The original address: hacks.mozilla.org/2017/02/a-c…
WebAssembly executes quickly. You’ve probably heard of it. But what makes WebAssembly so fast?
In this series of articles, I want to explain to you why WebAssembly is so fast.
Wait, what is a WebAssembly?
WebAssembly is a way to run non-javascript code in a browser. So when someone says WebAssembly is fast, they are comparing it to JavaScript.
I’m not suggesting that “it’s either/or” — you can either use WebAssembly or JavaScript. In fact, we want developers to be able to use both WebAssembly and JavaScript in one application.
But it’s helpful to compare the two so you can understand the potential impact WebAssembly has.
A bit of performance history
JavaScript was born in 1995. It wasn’t designed to run fast, and it certainly wasn’t fast enough for the first decade.
Then competition between browsers became fierce.
In 2008, the era of what everyone calls the Performance wars began. Many browsers have added just-in-time compilers, also known as JIts. When JavaScript code is running, the JIT can recognize the patterns in which the code is running and speed up the code based on those patterns.
JavaScript performance hit an inflection point with the advent of JIT, with JavaScript executing 10 times faster than before.
As performance improved, JavaScript began to be used in some unexpected areas, such as server-side programming using Node.js. Improved performance enables JavaScript to solve a whole new class of problems.
WebAssembly may bring another inflection point.
So, let’s dive into the details to understand what makes WebAssembly so fast.
background
- A crash course in just-in-time compiler (JIT)
- A crash course in assembly
Now the WebAssembly
- Create and use the WebAssembly module
- What makes WebAssembly so fast
The future of WebAssembly
- Where is WebAssembly now, and where do we go from here