官术网_书友最值得收藏!

序言(一)

I'm very excited to see this book, which covers in great detail a wide range of topics regarding WebAssembly. At this point in time WebAssembly is around one year old-if we count from when it shipped in all major browsers-so it's still fairly young, and the industry is just starting to figure out how revolutionary it is going to be. The potential is there for huge impact, and good documentation is necessary for that.

Why is WebAssembly's potential impact so large? For several reasons:

WebAssembly helps make the Web fast: WebAssembly is designed for small download size, fast startup, and predictably fast execution. The improvement compared to JavaScript can be very significant, over 2x in many cases, and especially in startup, where the speedup can be 10x.

WebAssembly makes the Web competitive with native: WebAssembly is designed as a compiler target for multiple languages. That includes C and C++, and in many areas of software the best implementations are in those languages, for example, game engines like Unity and Unreal, design software like AutoCAD, etc. It would take many years to write comparable products in JavaScript; instead, by compiling them to WebAssembly, the Web can be on par with native platforms today.

WebAssembly also fills an industry need outside the Web: WebAssembly is fast, portable, sandboxed, has multiple excellent open source implementations, and just like the Web itself it is an industry standard expected to be supported for the long term. As a result, it's not surprising that WebAssembly is starting to be used outside of browsers, for example in the blockchain and content delivery network (CDN)spaces.

Looking back, it's remarkable that our industry has gotten to this point. Just a few years ago, there was no cross-browser collaboration on getting native code to run on the Web. Instead, there were multiple options, including Native Client, Adobe Alchemy, and ASM.js, each with its own advantages and disadvantages. I believe it was the momentum of ASM.js that got the industry to focus on fixing things: ASM.js started out in Firefox, and by virtue of being a subset of JavaScript it immediately ran in all browsers-just not as efficiently. That led top companies in the video game industry and elsewhere to adopt ASM.js, together with Emscripten, the open source compiler to JavaScript that I started in 2010, and which could emit ASM.js. That adoption led to ASM.js support in Edge and later Chrome, at which point there was consensus that the industry should produce a proper standard in this space, which turned into WebAssembly. As the spec was designed and implementations started to appear, we added WebAssembly support to Emscripten, which allowed people to compile to both ASM.js and WebAssembly by just flipping a switch, making it easy for people to use the new technology. Finally, as of May 2018 Emscripten emits WebAssembly by default, and today WebAssembly has robust and stable support both in all major browsers and in the toolchain projects that emit it.

It's been a complicated path to get here, but the future looks bright. It is especially worth noting that WebAssembly is expected to add features like multithreading, SIMD, GC, and others, which will open up even more interesting opportunities.

Alon Zakai

Alon is a researcher at Mozilla, where he works on compile-to-Web technologies. Alon co-created WebAssembly and ASM.js, and created the Emscripten and Binaryen open source projects which are part of the primary WebAssembly compiler toolchain.

譯文:

我很高興能夠看到這本書的出版,作者在書中詳細地介紹了有關WebAssembly的各種主題。在這本書即將出版之際,WebAssembly差不多一歲了——如果從所有主流的Web瀏覽器開始支持WebAssembly算起,那么這項技術仍然相當年輕,業界也才剛剛開始意識到它將多么具有革命性。WebAssembly所擁有的潛力將會在未來對IT行業產生巨大的影響,但在此之前,我們需要有優秀的文檔。

為什么WebAssembly的潛在影響力會如此之大?有以下幾個原因。

WebAssembly讓Web應用運行更快。WebAssembly是一種新的格式,文件體積更小,啟動速度更快,運行速度也更快。與使用JavaScript構建的Web應用相比,性能提升非常明顯。在大部分情況下,運行速度提升兩倍以上,特別是在啟動速度方面,速度提升可以達到10倍。

WebAssembly讓Web應用能夠與原生應用展開競爭。WebAssembly是多種編程語言的編譯器目標,包括C和C++?;谶@些編程語言實現的優秀軟件,如游戲引擎Unity、Unreal,設計軟件AutoCAD等,如果使用JavaScript開發在功能上與這些軟件旗鼓相當的產品可能需要很多年時間。但如果將它們編譯成WebAssembly,這些原生應用就可以直接運行在Web平臺上。因此,Web能夠與原生平臺相提并論。

WebAssembly還在Web領域之外為行業帶來了其他可能性。WebAssembly運行速度快、可移植,提供了沙箱機制,并擁有眾多優秀的開源實現,就像 Web 本身一樣,它將會是一個被長期支持的行業標準。因此,WebAssembly開始被應用在Web瀏覽器之外的領域也就不足為奇了,例如區塊鏈和內容分發網絡(CDN)。

回首過去,我們的行業能夠取得如此的成就已經很了不起了。幾年前,還沒有人去進行這種跨瀏覽器協作,以便讓原生代碼運行在Web平臺上。不過有很多不同的項目,如Native Client、Adobe Alchemy和ASM.js,它們都在嘗試做同樣的事情,只是每個項目都有各自的優缺點。而我認為,是ASM.js的出現讓業界開始專注于解決這個問題——ASM.js最初出現在Firefox中,由于它是 JavaScript 的一個子集,因此可以無縫地運行在所有瀏覽器中,但運行效率不高。視頻游戲等行業的一些頂級的公司開始嘗試使用ASM.js和Emscripten(我在2010年開源的編譯器工具鏈,可以將代碼編譯成ASM.js)。由于在這些領域的廣泛應用,Edge以及后來的Chrome均開始支持ASM.js。此時,人們一致認為這個領域需要一個行業標準,于是WebAssembly出現了。

隨著規范設計和實現的不斷演進,我們在Emscripten中加入了WebAssembly支持——只需要在編譯命令中加入一個“開關”,便可選擇性地將編譯目標設置為ASM.js或WebAssembly,從而可以更輕松地使用這項新技術。截至2018年5月,Emscripten已經將默認的編譯目標類型改為WebAssembly。今天,WebAssembly已經在所有主流瀏覽器和工具鏈項目中得到了強大而穩定的支持。

一路走來歷經坎坷,但未來是光明的。特別值得注意的是,WebAssembly將會在未來添加多線程、SIMD、GC等功能,而這些新特性將會為我們帶來更多有趣的可能性。

Alon Zakai

Alon是Mozilla的研究員,從事與“編譯到Web平臺”相關的研究工作。Alon參與制定了WebAssembly和ASM.js 標準,并創建了 Emscripten和Binaryen等開源項目,這些項目都是WebAssembly編譯器工具鏈的重要組成部分。

主站蜘蛛池模板: 太康县| 莒南县| 日喀则市| 武威市| 呼玛县| 临海市| 黄山市| 深泽县| 大名县| 曲阜市| 卢氏县| 博湖县| 玉龙| 兰西县| 礼泉县| 乳源| 沂南县| 巴中市| 巴林右旗| 内乡县| 筠连县| 灵川县| 仁化县| 潮安县| 同德县| 博乐市| 旺苍县| 莆田市| 麻城市| 衡山县| 恩施市| 平阳县| 察雅县| 茂名市| 曲沃县| 青海省| 达拉特旗| 广宁县| 行唐县| 霍邱县| 同心县|