No Snakes on My Ladder: Winning at Software with Types
summary
A Snakes and Ladders single‑player simulator written in Rust demonstrates that encoding game states as types prevents impossible states (no square >100, no double‑rolls) by using newtype wrappers, enums for tiles, ownership and a type state pattern so only valid transitions compile. A mistaken phantom data approach reintroduces bugs. Nine common naive bugs vanish, test surface shrinks by ~2/3, and performance is comparable or better when the board is passed by pointer.
AI-written summary · about
chapters (11)
- 0:00Introduction and welcome
- 1:04Talk overview and Rust basics
- 8:57Invalid states in the game board
- 10:44State becomes type pattern
- 13:56Ownership and move semantics
- 16:44Phantom data pitfalls
- 19:53Where type state is used
- 20:59Multiplayer game challenges
- 24:28Costs and trade-offs of type state
- 26:42Seven key takeaways
- 28:30Q&A session
