I Wanted to Make a Game From Scratch, So I Started by Building the Computer

My journey through Parts 1 & 2 of the Nand2Tetris course, where I developed a 16-bit computer, assembler, VM translator, compiler, and my own game.

Published: Tue Aug 12 2025

“If you wish to make an apple pie from scratch, you must first invent the universe. - Carl Sagan” Link↗

This quote is a good reminder of how deeply connected things are, and how “from scratch” can mean starting far earlier than you might expect.
The Nand2Tetris course explores this idea in the context of computers, beginning with the simplest logic gate and ending with a working system that can run your own programs.

If you’re unfamiliar with it, Nand2Tetris along with its companion book “The Elements of Computing Systems: Building a Modern Computer from First Principles” guides you through building a computer from the ground up, in two parts.

Here is the big picture and the course starts us at the bottom with the NAND gate, working through abstraction by abstraction until we end up at human thought.

Big Picture

Here is a video about part one from the course.

Part 1: Hardware

By the end of Part 1, I had a simulator ready computer capable of running programs in Hack Assembly. Including of course, Tetris.

Here’s an example of HDL used to make chips and gates like the HalfAdder. This is similar to Verilog, a professional tool to make modern chips we use in our phones, computer, and other devices.

/**
 * Computes the sum of two bits.
 */
CHIP HalfAdder {
    IN a, b;
    OUT sum, carry;
    PARTS:
    Xor(a=a, b=b, out=sum);
    And(a=a, b=b, out=carry);
}

Part 2: Software

I implemented my Jack Compiler in Java (source), then wrote my VM Translator in Go (source) as a way to learn the language. With the Hack assembly generated, I used my Hack Assembler (source) written in Rust to produce the final machine code.

Bringing It All Together

With the toolchain above complete I can run my own game I created in Jack. Bat Dash, a simple dash game with animated sprites on the 512x256 1-bit pixel screen of the Hack computer. While this game is very simple, it was somewhat complex to implement on such a basic computer. The RNG logic was created from scratch and could use some improvements, but I’m satisfied with how the sprite animations turned out for the playable bat and the obstacles it dodges.

Bat Dash Example

I went through both parts 1 and 2 on Coursera. If you’ve ever been curious about building a computer from the ground up, I can’t recommend the experience enough. It’s equal parts challenging, surprising, and fun.