HTML / CSS / JS / WASM Following HTML, CSS and JavaScript, WebAssembly becomes the fourth language for the Web which allows code to run in the browser in 2019
WASM Low-level Language // c int add(int x, int y) { return x + y; } // rust fn add (x: u32, y: u32) -> u32 { x + y } // AssemblyScript function add(x: i32, y: i32): i32 { return x + y; }
Run with near-native - Predictable performance - Optimized for fast load and execution - Efficient memory management - Use 'better' language to solve a certain problem
High-Level Low-Level - Less slow than - Runtime optimization - Loose memory management - Runtime error - Promised performance - Efficient memory management - Rooms for performance improvement - Reuse popular libraries - Easy to learn, low learning curve - No compile and build - No need for memory management 👎 👍 👍 👎 - Hard to learn - Compile and build to run - Difficult memory management - Poor programming productivity
Javascript WebAssembly - Compiles, and builds to run - Optimized performance - Promised predictable performance - Efficient memory management - Easy to code and run - Less slow than - High cost for peak performance - Better experience in DOM/Web APIs - Make a small or simple code - Code and check the result often - Call a DOM, Web APIs frequently - Make a hot-path code
- Different to Grandma's VM - Virtual Instruction Set Architecture (V-ISA) - Written in a variety of languages, C/C++, Rust, Go, AssemblyScript, ... - Linear Memory, Implicit Stack, Some Instructions - No operation system access and built-in functions - Running on trusted runtimes, V8, SpiderMonkey, Wasmtime, Lucet, WAMR, Cranelift, ... Virtual Machine