Skip to content

Instantly share code, notes, and snippets.

@fnh
Last active May 28, 2017 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fnh/7c62ad21f5a40e7ac76b7ee161c28aa7 to your computer and use it in GitHub Desktop.
Save fnh/7c62ad21f5a40e7ac76b7ee161c28aa7 to your computer and use it in GitHub Desktop.
# WebAssembly (http://webassembly.org/)
Open Web Standard, developed by W3C Community Group
"portable, size- and load-time-efficient format suitable for compilation to the web."
Supported by all major browser vendors (v1 available in Chrome, Firefox, Safari, Edge; partly behind flag)
Write once - run anywhere? The VM which kept that promise is the browser and JS has for long been is its only native language.
Highlevel Language (C, C++, Rust) -> Intermediate Representation (IR) -> wasm -> x86/ARM
WebAssembly is a instruction set for a conceptual machine (Stack machine)
Emscripten - emcc hello.c -s WASM=1 -o test.html
Calling WebAssembly from JS.
let importObject = {};
fetch('some.wasm')
.then(response => response.arrayBuffer())
.then(bytes => WebAssembly.instantiate(bytes, importObject))
.then(results => {
console.log(results.instance.exports);
});
Example
https://github.com/JasonWeathersby/WASMSobel
MDN Docs
https://developer.mozilla.org/en-US/docs/WebAssembly
WasmFiddle
https://wasdk.github.io/WasmFiddle//
WASM Explorer
https://mbebenita.github.io/WasmExplorer/
Talks
* Compiling for the Web with WebAssembly (Google I/O '17) https://www.youtube.com/watch?v=6v4E6oksar0
* WebAssembly Demystified https://www.youtube.com/watch?v=cRwUD5SxF4o
* A cartoon intro to WebAssembly https://www.youtube.com/watch?v=HktWin_LPf4
https://hacks.mozilla.org/category/a-cartoon-intro-to-webassembly/
Future
* Threads
* Direct DOM Access / Browser APIs
* SIMD
* Support for GC-languages
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment