Brandan

The same path tracer, twice — JavaScript vs Rust → WASM.

JS vs WASM

Both panels run the same Monte-Carlo path tracer on identical 320×240 canvases: the left is Rust compiled to WebAssembly, the right a line-for-line JavaScript port. Each animation frame, every engine that hasn't finished traces one full sample per pixel. Watch which image converges first.

Rust → WASM

 

JavaScript

 

 

Loading WASM module…

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