Game of Life
On November 5, 2022, I went to a Code Retreat in Bethesda, MD. While there, I chatted with Samuel, a Data Scientist from Spain, who had built The Game of Life with Rust and WASM. His primary goal was to get a proof-of-concept with Rust and WASM working, but he mentioned that it was the only way he could get The Game of Life to render at 120fps.
I took that as a challenge, so here's my single-thread, JS-only
implementation that runs at 60fps on my laptop (because requestAnimationFrame()
only runs at 60fps on my
machine). I believe this can hit 120fps because the browser still has
some idle time when running a performance benchmark.
It's a litte slow for the first few seconds while the page's React hydrates. However, The Game of Life code is 100% vanilla JS.
In this version, the business logic is running on the main thread. I also implemented a version where the business logic runs in a Web Worker.