← All demos

Speed race · Rust vs JavaScript

JS vs WASM

The same Monte-Carlo path tracer implemented twice — once in Rust compiled to WASM, once as an idiomatic JavaScript port — racing on identical 320×240 canvases. Watch which image converges first.

Rust → WASM

 

JavaScript

 

 

Loading WASM module…

Caveat: the JS port is idiomatic but unoptimized — it allocates a new object per vector operation, which is exactly the overhead Rust's stack-allocated value types avoid. That difference is part of the point.