WebAssembly & Web Workers Vocabulary
0 / 5 completed
Exercise 1 of 5
The frontend engineer says: 'We compile the image processing library from Rust to WebAssembly — it runs at near-native speed in the browser, no server round-trip needed.'
What is WebAssembly (WASM)?
WebAssembly is a binary compilation target for the browser. Code written in C, C++, Rust, Go, etc. can be compiled to WASM and run alongside JavaScript at near-native performance.
Exercise 2 of 5
The developer explains: 'We moved the PDF generation to a Web Worker — it runs in a separate thread so the UI stays responsive. Workers communicate with the main thread via postMessage.'
Why are Web Workers used?
Web Workers run JavaScript in a background thread. They communicate with the main thread via postMessage. This keeps the UI thread responsive during heavy computation like PDF generation, parsing, or encryption.
Exercise 3 of 5
The team architect says: 'We use SharedArrayBuffer with Atomics to share memory between our WASM module and the main thread — no copying, just direct memory access.'
What is SharedArrayBuffer in the context of WASM and Workers?
SharedArrayBuffer is a fixed-length raw binary buffer that multiple threads (Workers and main thread) can access simultaneously. Atomics provides synchronization primitives to prevent race conditions.
Exercise 4 of 5
The performance engineer says: 'Our linear memory grows from 16MB to 256MB — we allocate buffers in WASM memory, pass pointers across the JS/WASM boundary, and the GC handles the rest.'
What is WASM linear memory?
WASM linear memory is a flat, contiguous byte array. WASM code operates on it using integer addresses (pointers). JavaScript can read and write it as an ArrayBuffer — enabling data exchange across the JS/WASM boundary.
Exercise 5 of 5
The engineer says: 'We use wasm-bindgen to generate JavaScript bindings for our Rust WASM module — raw WASM only handles integers, but wasm-bindgen lets us pass strings, objects, and closures.'
What problem does wasm-bindgen solve?
Raw WASM only supports numeric types. wasm-bindgen generates JS and Rust glue code that marshals strings, arrays, closures, and objects across the boundary — making Rust WASM functions feel native to JS callers.