Experiments 01

Game of Life

Draw on the grid to add cells. Run the simulation, or switch between Rust and JavaScript to compare their execution times.

Rust · WASM · CanvasView source 

loading engine…
generation
alive
peak
tick
Notes on how it works

Notes

The rules

  • A live cell with fewer than two neighbours dies.
  • A live cell with two or three neighbours survives.
  • A live cell with more than three neighbours dies.
  • A dead cell with exactly three neighbours is born.

Why WASM

Every generation touches every cell and its eight neighbours. Rust does that on a contiguous buffer with no allocation; JavaScript can read the result straight out of linear memory, and the canvas uses that buffer to draw the cells.