Why Rust Is Eating WebAssembly
Last week, we shipped a critical data processing pipeline. It runs entirely in the browser, processes 10GB of data without stalling the UI, and weighs 180KB. It took two days to build.
The secret? Rust compiled to WebAssembly, with just enough JavaScript glue to talk to the DOM. This isn't a toy demo — it's running in production, handling real customer workloads.
The Browser Is Now a Real Runtime
For years, we accepted that browsers were for JavaScript. Everything else was a compromise. TypeScript helped, but it's still JavaScript under the hood. The performance ceiling was real.
WebAssembly changed the game. But more importantly, Rust changed how we think about targeting the web.
Here's why this combination works:
- Zero-cost abstractions actually mean zero cost
- No garbage collection means predictable performance
- The borrow checker catches data races before they ship
- The ecosystem (wasm-bindgen, trunk, yew) is mature
A Real Example
We needed to parse PDFs client-side. The JavaScript library we tried was 2MB and took 4 seconds to process a document. The Rust replacement is 150KB and processes the same PDF in 200ms.
The code is surprisingly readable:
#[wasm_bindgen]
pub fn extract_text(data: &[u8]) -> Result {
let doc = Document::load_from(data)?;
let mut output = String::new();
for page in doc.pages() {
for text in page.text_objects() {
output.push_str(&text.content);
}
}
Ok(output)
}
That's it. No async/await complexity. No memory leaks. It just works.
The Development Experience
I'll be honest: Rust has a learning curve. But it's a different kind of curve than JavaScript's. With JavaScript, you pay the cost at runtime. With Rust, you pay it at compile time.
Here's what surprised me most:
Hot reloading works. Using trunk, changes compile in under a second. The feedback loop feels faster than JavaScript bundlers for small projects.
Debugging isn't bad. Source maps work. You can set breakpoints in Rust code and step through it in Chrome DevTools. It feels native.
The bundle size is tiny. Our entire application, including a custom PDF renderer, is smaller than React alone.
When Not To Use It
Rust isn't always the answer. If you're building a content site, stick with static HTML. If you need rapid prototyping, JavaScript's dynamic nature shines. The FFI boundary adds complexity you might not need.
But for compute-heavy tasks? For applications where every millisecond matters? For code that needs to run reliably without memory leaks? Rust + WASM is now my default.
The Broader Implications
This isn't just about browsers. The same WASM modules run in edge functions, embedded devices, and serverless environments. Write once, run anywhere finally feels true.
At Sunset Beach, we're betting on this stack. Our next product is entirely Rust + WASM, from the edge to the browser. The development velocity is higher, not lower. The bugs are fewer. And our users notice the difference.
The future of web development isn't JavaScript vs. Rust. It's choosing the right tool for each boundary. And increasingly, that boundary is WebAssembly.
← Back to Home