WebAssembly
in action
@mafintosh
Low level programming for the web
What is assembly?
Machine friendy language that compiles to machine code
1 + 2
→ assembly
push 1
push 2
add
    
push 1  →  0x1 0x1
push 2  →  0x1 0x2
add     →  0x3
    
Assembly is close to the metal
Almost no abstractions
Hard to maintain
Use assembly to implement STABLE functions that are super FAST
Hash functions, video encoding, cryptography
WebAssembly is assembly for the web
Node.js 8+, Chrome, Firefox, Safari 11, Edge preview
WAST is a Lisp like language that compiles to WebAssembly
npm install -g webassembly-binary-tools
wast2wasm example.wat -o example.wasm
    
(demo)
npm install -g wast2js
wast2js example.wat -o example.js
    
npm install -g wast2js
wast2js example.wat -wo example.js
    
(demo)
LOTS of instructions
http://webassembly.org/docs/semantics
When operating on non-numbers (buffers / strings) you have to copy data and use pointers
(demo)
WebAssembly will massively speed up algorithms that rely on 64 bit integers
BLAKE2b is a very fast hash function that does exactly that
npm install blake2b
https://github.com/mafintosh/siphash24 https://github.com/mafintosh/blake2b-wasm https://github.com/mafintosh/webassembly-binary-tools https://github.com/mafintosh/wast2js http://webassembly.org/docs/semantics
Thank you!