The Game of Life, in one language after another
The problem
I wanted a way to really get to know a new programming language, not just read about it. Conway’s Game of Life is a good problem for that. It is a grid of cells, each alive or dead, and every generation the same rules apply: a live cell with two or three live neighbours survives, an empty cell with exactly three becomes alive, and every other cell dies or stays empty. The rules fit in one sentence, but a working version still needs a grid, a loop, input and graphics. So I decided to write it again in every language I want to learn.
What I built
Three versions so far, all in one repository.
Python, in June 2025. First the rules on their own, printed in the terminal as rows of X and O. Then a window with Pygame: Space pauses, R fills the board at random, C clears it, the arrow keys change the speed, and a click flips a cell. The edges wrap around, so a pattern that leaves on one side comes back on the other.
JavaScript, in July 2025. The same logic drawn on an HTML canvas, with clicking to change cells and P to pause.
C, in March 2026. A terminal version first, where you type the coordinates of the cells to flip, then a window with raylib on a 100 by 100 board. It adds zooming with the mouse wheel and panning with the right mouse button or the arrow keys. I built it on Arch Linux and cross-compiled it for Windows.
Here is a board to play with, rebuilt for this page with the same rules and the same wrapping edges:
Click or drag on the board to draw cells. The edges wrap around, as in my versions. With the keyboard: tab to the board, move with the arrow keys, press Space to set or clear a cell and P to play or pause.
Game of Life board
What went wrong
Mostly performance. Every generation looks at all eight neighbours of every cell, so a large board means a lot of work many times a second, and keeping it smooth took more effort than getting the rules right.
What I learned
The different natures of the languages. The rules never change, so writing them again shows clearly how differently each language wants you to think.
Cellular automata are something I want to do more with, and I think they make great projects for learning programming. The series is not finished: I plan to add the languages I want to get familiar with next.
This site runs on the Game of Life too: the faint cells behind the home page and the way the text dissolves when you switch languages follow the same rules.