原文:A cartoon intro to WebAssembly
本文译自Lin Clark 关于 WebAssembly 的卡通介绍系列,渣翻译,因此附上英文原文
- 概述:
- WebAssembly 的漫画介绍
- 背景:
- 现在的 WebAssembly:
- 未来的 WebAssembly:
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.
你可能听说过, WebAssembly
很快,但是它为什么很快呢?
在这个系列,我会解释它为什么很快。
等等,那么什么是 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.
WebAssembly
是一种使其他语言而非 JavaScript 编写的代码在浏览器中运行的方式。所以当人们说 WebAssembly
快,是因为和 JavaScript 比较。
现在,我不想暗示这是一个二选一的情况:你要么使用 WebAssembly
或者使用 JavaScript。事实上,我们希望开发人员在同一个应用程序中同时使用 WebAssembly 和 JavaScript。
但是比较两者是有用的,你可以了解 WebAssembly
将具有的潜在影响。
一点关于性能的历史
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.
JavaScript 是在 1995
年创建的。它并不被设计得很快,在第一个十年,它不是很快。
然后,浏览器开始变得更有竞争力了。
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.
2008 年,人们称之为表演战的时期开始了。多个浏览器添加了即时编译器,也称为 JIT
。当 JavaScript 运行时,JIT
可以看出模式,并根据这些模式使代码运行得更快。
JIT
的引入正是了 JavaScript 性能转折点。JS 的执行速度提高了 10
倍。
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.
随着性能的改进,JavaScript 开始被用于以前没有人想过的地方,像使用 Node.js
的服务器端编程。性能改进使得使用 JavaScript
在一整个新类别的问题上变得可行。
现在有了 WebAssembly
,我们可能会在另一个拐点。
So, let’s dive into the details to understand what makes WebAssembly fast.
所以,我们来详细了解一下是什么使 WebAssembly
快速。