Skip to content

Instantly share code, notes, and snippets.

@fnh
Last active May 28, 2017
Embed
What would you like to do?
# 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