Lesson 8 of 9 · 19m
Use Cases That Justify the Complexity
The workloads where Wasm earns its keep — codecs, compression, parsing, simulation, cryptography-adjacent kernels — and the ones where it's architectural vanity.
The strongest Wasm adoption I've seen doesn't start with 'let's use Wasm.' It starts with a painful kernel: image processing too slow in JS, a mature C library with no usable port, deterministic simulation needed on both server and client, or a parsing workload melting mobile CPUs. If you can't name the kernel, you don't have a use case.
Strong fits
Codecs and media transforms. Image resizing, audio DSP, video filtering, compression. They are byte-oriented, numerically intense, and often already implemented in C/C++/Rust.
Parsing and validation of binary formats. PDF pieces, protobuf decoding, CAD files, genome data, large log formats. Wasm shines when input is untrusted but self-contained.
Deterministic simulation. Physics, games, financial modeling, Monte Carlo workloads. The same compiled kernel can run in browser and server with fewer language-specific discrepancies.
Shared business logic with tight constraints. Rules engines, policy evaluation, license validation — but only when the logic is substantial enough to justify an ABI. 'Validate an email' is not substantial.
Weak fits
DOM rendering, form validation, CRUD orchestration, general state management, and anything mostly shuttling JSON between services. Those are host integration problems. Moving them into Wasm adds a serialization layer and then congratulates you for solving a problem you created.
A quick sniff test:
Good Wasm kernel:
input: typed arrays / bytes
output: typed arrays / compact binary
runtime: milliseconds to seconds of numeric work
chatty host interaction: no
Bad Wasm kernel:
input: object graph plus DOM state
output: UI mutations
runtime: microseconds per operation
chatty host interaction: constantlyReuse beats rewrite
One of Wasm's best uses is not performance at all — it's reuse of mature implementations. SQLite, zlib/brotli-style compression, game engines, cryptography libraries compiled by expert-maintained projects. Do not write your own crypto because Wasm makes it easy to ship. Use audited implementations and understand the difference between memory-safe execution and cryptographic correctness.
Portability is real but bounded
The same .wasm often runs in browser, edge runtime, and server runtimes, but imports differ. A browser module expecting DOM-adjacent glue will not run unchanged in WASI. Design the kernel pure and keep host adapters thin.
Field notes
- 'Mature library already exists' is often a stronger argument than raw speed.
- If a kernel runs once per page load, complexity probably outweighs benefit.
- If it runs continuously on user input or large files, start measuring.
- The best Wasm APIs look boring: initialize, process buffer, finish, free.
Was this lesson helpful?