Rust compiles to WebAssembly for near-native speed in browsers and edge runtimes. Tools like wasm-pack bridge Rust modules to JavaScript hosts—compare with JavaScript for UI glue.
Typical flow
- Write Rust library crate targeting
wasm32-unknown-unknown - Build with wasm-pack
- Import WASM module from JS/TS bundler
Important interview questions and answers
- Q: Why Rust for WASM?
A: Predictable performance, small binaries, and no GC pauses in the WASM module—good for compute-heavy browser tasks.
Self-check
- What target triple is common for browser WASM?
- Who calls exported WASM functions?