Rust and WASM - Game of Life
TL;DR: Playable game of life in this post, written in Rust, running with WebAssembly. I started learning Rust a while ago, when I was trying to get a handle on OS development. I followed along with Philipp Oppermann’s blog but quickly put Rust aside for C and the osdev wiki.
I wanted to come back to Rust and, while I was here, learn WebAssembly too. A side project of mine recently ran up against yul which has a very wasm-like syntax (I believe it can target either eWASM or the EVM), so two-birds-one-scone.
I did the Rustlings course using CLion with the Rust plugin and EduTools plugin first, then finally dove into the rust-wasm tutorial. The tutorial walks you through implementing Conway’s Game of Life in Rust, building it for WebAssembly, and interacting with it through Javascript. It was pretty fun, I highly recommend giving it a try.
Anyway, here’s the interactive Game of Life. I ended up using FixedBitSet
for the cells, from one of the optional tutorial exercises. The slider controls
the game speed and you can click any cell to toggle it. Press Play (▶) to start!