Hellooo FOSDEM!
Last updated: 2019-02-02
Szmozsánszky István "Flaki"
@slsoftworks
Developer Outreach / DevRel
Mozilla TechSpeakers
Tessel Project, JS+HW hacker
Speed without Shenanigans
István Szmozsánszky "Flaki"
@slsoftworks
[]()
…a.k.a. WebAssembly & Compile-to-JavaScript’s Rise to Fame
Our story starts around the JS-engine perf wars…
The rise of Compile to JS
Emscripten & asm.js
Although Emscripten & the asm.js format wasn’t the first attempts at this, they ended up being the one proving beyond doubt that the idea of "compiling large, pre-existing codebases to JavaScript" and running them in the browser’s JS VM is not only feasible, but desirable on today's web.
Around this time many parties got fairly excited about "compiling to JavaScript", but one in particular has jumped on the bandwagon early on, and remain a key supporter of the compile-to-js ecosystem:
The gaming industry
Today the web is the biggest app dev platform
…and the largest open distribution platform
Many ways the same—but also very different
Seeded by the idea of repurposing the existing optimizing JavaScript VM in browsers with the feasibility of reusing pre-existing low-level (C/C++) codebases the web platform started exploring new frontiers.
Tools like Emscripten and the standardization of asm.js made it possible to compile low-level languages to a subset of JavaScript to be executed with high speeds by the JS VM. This kickstarted a whole new ecosystem of compile-to-JS libraries, tooling & applications, and eventually paved the way for an incremental update building on these foundations and incorporating ideas from other efforts (like (P)NaCL) in the field:
A joint effort
work-in-progress
- An efficient stack machine
- Binary representation + text format
- Open & debuggable
- A complement to the web—not a competitor
Ditching the makeshift JS form compresses the code over the wire & improves loading speeds (in Firefox WASM is compiled faster than it comes through the wire!), while WASM code itself supports an initial limited set of numeric types and is executed by the browser with similar safety guarantees as JavaScript (usually running inside the same VM as JS).
Some of these limitations are due to the MVP-nature of the current specification, but some are intentional — WASM is built to communicate extensively with other parts of the browser/JS APIs, and to extend, rather than replace its existing functionalities.
Nebulet
In short, Nebulet is an operating system that runs WebAssembly.
Under the hood, Nebulet is a microkernel that executes WebAssembly modules in ring 0 and a single address space to increase performance.
Like, there is now an experiment, titled Nebulet, which is an attempt to create a prototype WebAssembly kernel, running exclusively WebAssembly applications.
The WebAssembly MVP is a fair bit more down-to-Earth in its approach, yet it still brings a crucial, deeply missed tool to the web platform…
Lower-level abstractions for performance & control are not new
A potential fix…
Saving millions of dollars in production with WebAssembly
…or replacing parts of your browser with it
The lurking secret sauce: Rust
⚡
Speed Without Wizardry
Expanding what's possible today in the browser
The not-so-secret purpose of this talk is to whet your appetite to know more about this exciting feature of the web platform.
Some of the points I made would have deserved their own talks (which I'll probably need to cater for at some point, at least in the form of a blogpost), but if you are interested in any of them in more detail, be sure to find me after the talk or reach out to me on Twitter (@slsoftworks) or any of my other contacts at flak.is.
Thanks!
talk.flak.is/wasm/fosdem-2019
@mozhacks
@slsoftworks
Reading list:
- The ASM.js FAQ with Alon's original presentation
- WebAssembly is more than just Web - and definitely more than just the revival of Flash - articles by Steve Klabnik
- Understanding WAT, the WebAssembly Text Format - an MDN guide by Chris Mills
- A workshop-style intro to Rust+WebAssembly & wasm-bindgen by Ashley Williams & Steve Klabnik
- Hack Without Fear! — Fearless concurrency in Rust and in Servo/Firefox
- An explainer on wasm-bindgen by Alex Crichton and wasm-pack by Ashley Williams
- WebP image decoding using WebAssembly & emscripten
- Mozilla's streaming & tiered WebAssembly compilation - a blogpost by Lin Clark and V8's WebAssembly baseline compiler: Liftoff
- Nick Fitzgerald's post on embedding WASM in the devtools with Vyacheslav's response & Nick's followup
- Dan Callahan presents about WebAssembly at JSConf Budapest, runs DOS & Netscape in a browser
- WebAssembly's post-MVP future article & talk recording, by Lin Clark, Till Schneidereit, Luke Wagner