Horacio Gonzalez @LostInBrittany Spaniard lost in Brittany, developer, dreamer and all-around geek
Flutter
Slide 3
OVHcloud: A Global Leader 200k Private cloud VMs running
1
Dedicated IaaS Europe Own 20Tbps Netwok with 35 PoPs
30 Datacenters
Hosting capacity : 1.3M Physical Servers 360k Servers already deployed
1.3M Customers in 138 Countries
Slide 4
Did I say WebAssembly? Wasm for the friends…
Slide 5
WebAssembly, what’s that?
Slide 6
A low-level binary format
Not a programming language A compilation target
Slide 7
That runs on a stack-based virtual machine
A portable binary format that runs on all modern browsers… but also on NodeJS and elsewhere!!
Slide 8
With several key advantages
Slide 9
But above all…
WebAssembly is not meant to replace JavaScript
Slide 10
Who is using WebAssembly today?
And many more others…
Slide 11
A bit of history Remembering the past to better understand the present
Slide 12
Executing other languages in the browser
A long story, with many failures…
Slide 13
2012 - From C to JS: enter emscripten
Passing by LLVM pivot
Slide 14
Wait, dude! What’s LLVM?
A set of compiler and toolchain technologies
Slide 15
2013 - Generated JS is slow…
Let’s use only a strict subset of JS: asm.js Only features adapted to AOT optimization
Slide 16
WebAssembly project
Joint effort
Slide 17
Hello W(asm)orld My first WebAssembly program
Slide 18
I don’t want to install a compiler now…
Let’s use Wasm Explorer https://mbebenita.github.io/WasmExplorer/
Slide 19
Let’s begin with the a simple function
WAT: WebAssembly Text Format Human readable version of the .wasm binary
Slide 20
Download the binary .wasm file
Now we need to call it from JS…
Slide 21
Instantiating the Wasm 1. Get the .wasm binary file into an array buffer 2. Compile the bytes into a WebAssembly module 3. Instantiate the WebAssembly module
Slide 22
Instantiating the WASM
Slide 23
Loading the squarer function
We instantiate the WASM by loading the wrapping JS
Slide 24
Using it!
Directly from the browser console (it’s a simple demo…)
Slide 25
Features of Wasm Why is everybody looking at it?
Slide 26
Near native speed
https://medium.com/wasmer/benchmarking-webassembly-runtimes-18497ce0d76e
Slide 27
Highly portable
It can be run almost everywhere…
Slide 28
Readable and debuggable
Each .wasm file with it .wat companion file
Slide 29
Memory safe & secure
Running in a fully sandboxed environment
Slide 30
Accepting many source languages
And more and more…
Slide 31
Some constraints Still a young platform
Slide 32
Native WASM types are limited WASM currently has four available types: ● ● ● ●
i32: 32-bit integer i64: 64-bit integer f32: 32-bit float f64: 64-bit float
Types from languages compiled to WASM are mapped to these types
Slide 33
How can we share data?
Using the same data in WASM and JS? Shared linear memory between them, and serializing the data to one Wasm types
Slide 34
Solution is coming: Interface types
Beautiful description at: https://hacks.mozilla.org/2019/08/webassembly-interface-types
Slide 35
No outside access
By design, communication is done using the shared linear memory only
Slide 36
Solution exists: WASI
Slide 37
Mono-thread and scalar operations only
Not the most efficient way…
Slide 38
Solution exists: SIMD
Slide 39
Solutions are coming too: Wasm Threads
Threads on Web Workers with shared linear memory
Slide 40
Incoming proposals: Garbage collector
And exception handling
Slide 41
Server-side WebAssembly Too good to not to use it
Slide 42
Solomon on Web Assembly
Slide 43
Solomon on Web Assembly
Slide 44
A very interesting feature set
Slide 45
The Bytecode Alliance Taking WASM out of the browser
Slide 46
The Bytecode Alliance
Slide 47
Bytecode Alliance projects
Slide 48
Wasmtime
Slide 49
Cranelift
Slide 50
WebAssembly Micro Runtime
Slide 51
Lucet
Slide 52
Other runtimes Runtimes, runtimes everywhere
Slide 53
Wasmer
Run any code* on any client… almost * Languages compiling to WASM
Slide 54
Wasmer
Slide 55
Wasmer ecosystem
Slide 56
Wasmer ecosystem
Slide 57
Wasm3
Slide 58
Wasm3
Slide 59
And even Wasm over GraalVM!
Slide 60
Some examples IRL? Like companies using these things