WASM promised to made web apps much faster, and so a growing number of application can move on the web.
It happen that WASM is also relevant on the server, thanks to WASI (WebAssemby System Interface) that allow programs compiled in WASM to access the server system calls.
The WASM bytecode is very small in size, also fast, and safe as the WASM specifications was written with the browser and the web in mind (we have a long experience on security issues and learned a lot from that).
Docker launched a beta version of Docker Desktop that allow running WASM binaries without an image.
Let's look what that means and how can it be cool to have this in the future.
4. Run WASM on Docker
Docker Engine
Containerd
containerd-shim containerd-shim containerd-shim
runc runc wasmedge
Container process Container process Wasm Module
8. How Good Stuff Usually Came From
«Amateurs sit and wait for
inspiration, the rest of us just get
up and go to work.»
Stephen King
9. From JavaScript to asm.js
Source Code AST
Bytecode
Baseline
Compiled
Code
Ion-
Compiled
Code
Run
Run & Profile
Parse Generate
Compile
Compile
Bail
10. Mozilla asm.js
Source Code AST
Bytecode
Baseline
Compiled
Code
Ion-
Compiled
Code
Run
Run & Profile
Parse Generate
Compile
Compile
Bail
asm.js
11. WebAssembly
WebAssembly is a binary instruction format for a stack-
based virtual machine.
...is designed as a portable compilation target for
programming languages, enabling deployment on the web
for client and server applications.
webassembly.org
12. What’s make WASM so cool
●
Efficient and fast
●
Safe
●
Open and debuggable
●
Part of the open web platform
13. Efficient and fast
●
Compact in size
●
Fast load time
●
Execution at “native speed”
●
Binary format
●
Can take advantage of the hardware*
15. Part of the open web platform
●
Designed to enforce versionless,
feature-tested, backward-compatible
●
Callable in and out from JavaScript
●
Accessing the web API
...but it’s not limited on that platform...
16. How it Works on the Web
●
Load the .wasm file from JavaScript
●
Compile it with the WebAssembly
interface
●
Instantiate the module through
JavaScript
●
Access the exported functions
18. How to Work on the Browser
function instantiate(bytes, imports) {
return WebAssembly
.compile(bytes)
.then(m => new WebAssembly.Instance(m, imports));
}
var importObject = {
imports: {
i: arg => console.log(arg)
}
};
fetch('simple.wasm')
.then(response => response.arrayBuffer())
.then(bytes => instantiate(bytes, importObject))
.then(instance => instance.exports.e());
19. WebAssembly System Interface
●
It’s designed to be independent from Browsers
and web APIs or JavaScript
●
Inspired by POSIX
●
Focused on portability and security
●
A modular set of standard interfaces
20.
21. WIP
●
WASI is still Work In Progress
●
WASI-CORE is the starting point
●
There are also open points:
– Asynchronous I/O
– File watching
– File locking
22. WASM 2.0 and Beyond
●
Tail calls → standardized but still not ready
●
Exception handling
●
Garbage collection
●
Memory64
●
Multiple memory
●
Relaxed SIMD
●
Threads and atomics
●
Type reflection
23. Conclusions
●
WASM is not ready on the server yet
●
It’s a pretty good portable format
●
Running WASM as a container it’s really
promising
●
WASI is still in a early stage