Web Assembly
Web 应用程序较于原生应用之短在于性能。当然性能的问题不在于比较跑分高下,而在于用户体验。试想象一下,浏览器直接执行的游戏引擎代码是优化过的二进制中间表达形式(IR),甚至可能是缓存下来的后端转换过的机器码。WebApp与Native App再战一轮?
谷歌等巨头拟推全新网络应用标准WebAssembly,旨在提高编译后Web应用程序的性能。
Google/微软/苹果联手:浏览器提速20倍! WebAssembly是一种可用于未来浏览器中的字节码(bytecode),可使浏览器性能提升20倍。字节码是一种机器可读的指令集,与高级语言相比,字节码的加载速度更快。WebAssembly项目旨在开发全新的字节码,从而让桌面和移动端浏览器变得更高效。
W3C WebAssembly Community Group
- https://www.w3.org/community/webassembly/
- The mission of this group is to promote early-stage cross-browser collaboration on a new, portable, size- and load-time-efficient format suitable for compilation to the web.
- Chairs: Luke Wagner (Mozilla), Jean-Francois Bastien (Google), BRHAM GIRI ABHIJITH CHATRA (Microsoft).
- Non-Chair participants: 317 as of 20150701; 357 as of 20150713.
- Mailing lists: public-webassembly, public-webassembly-contrib, internal-webassembly.
- IRC:
irc://irc.w3.org:6667/#webassembly
.
GitHub WebAssembly Organization
- https://github.com/WebAssembly: Development of WebAssembly and associated infrastructure.
- design: WebAssembly Design Documents.
- experimental: Loosely-coupled collection of quick-and-dirty experiments.
- interpreter-prototype: A very early experimental prototype WebAssembly interpreter.
- js-astcompressor-prototype: Research prototype for investigating binary AST representation approaches.
- polyfill-prototype-1: Experimental WebAssembly polyfill library and tools.
- v8-native-prototype: Prototype native decoder that targets TurboFan.
Note:
- AST is an abbreviation of abstract syntax tree. This research prototype is experimenting to find the best balance of post-compression size, pre-compression size, complexity, and decode speed.
- TurboFan is a codename of a new, experimental optimizing compiler for Google’s V8 JavaScript engine.
WebAssembly Design Documents
High Level Goals
- Define a portable, size- and load-time-efficient binary format.
- Specify and implement incrementally: Minimum Viable Product (MVP) primarily aimed at C/C++, polyfill, essential post-MVP features, future features.
- Design to execute within and integrate well with the existing Web platform.
- Design to support non-browser embeddings as well.
- Make a great platform: build a new LLVM backend for WebAssembly and an accompanying clang port; promote other compilers and tools targeting WebAssembly; and enable other useful tooling.
FAQ
- Why create a new standard when there is already asm.js?
- What are WebAssembly’s use cases?
- Can the polyfill really be efficient?
- Is WebAssembly only for C/C++ programmers?
- What compilers can I use to build WebAssembly programs?
- Will WebAssembly support View Source on the Web?
- What’s the story for Emscripten users?
- Is WebAssembly trying to replace JavaScript?
- Why not just use LLVM bitcode as a binary format?
Use Cases
How WebAssembly can be used?
- Entire code base in Web Assembly.
- Main frame in Web Assembly, but the UI is in JavaScript / HTML.
- Re-use existing code by targeting Web Assembly, embedded in a larger JavaScript / HTML application. This could be anything from simple helper libraries, to compute-oriented task offload.
Other Documents
- AST Semantics: Abstract Syntax Tree Semantics: types, linear memory, local/global variables, control flow structures, calls, literals, expressions with control flow, 32/64-bit integer operations, floating point operations; datatype conversions, truncations, reinterpretations, promotions, and demotions.
- Binary Encoding: portable binary encoding of the Abstract Syntax Tree nodes, designed to allow fast startup, which includes reducing download size and allow for quick decoding.
- Text Format: The text format is equivalent and isomorphic to the binary format.
Conclusion
WebAssembly is two things (at least):
- Standardized way across all the browser houses to enable hybrid applications – on many dimensions.
- Key component in Google OS convergence; kills NaCL and PNaCL.