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 neighbors dies.
  • A live cell with two or three neighbors survives.
  • A live cell with more than three neighbors dies.
  • A dead cell with exactly three neighbors is born.

Why WASM

Every generation touches every cell and its eight neighbors. 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.