The game above is written in Jack and was my submission for my nand2tetris project.
building a computer
Through the past month, I built a fully working Hack computer from scratch following the Nand To Tetris curriculum. Check out the project I built to run on this computer with the Jack language:
This game runs on a physical keyboard, so it's playable on desktop only. Open this page on a computer to give it a try.
Click the screen to give it focus, then use the keyboard. Arrow keys and letter keys are mapped to Hack keycodes. The game explains its own rules on the start screen.
Every layer that makes up the Nand2Tetris Hack computer. Built from scratch.
Compiles the object oriented Jack language into to stack-based VM code.
Turns the stack-based virtual machine language into Hack assembly code.
Translates Hack assembly code into 16-bit binary machine code.
A standard library in Jack: graphics, math, memory, strings and I/O. Implements efficiency focused algorithms.
Wires the CPU to RAM and memory-mapped screen + keyboard.
Fetches each instruction and drives the ALU, registers and counter. Takes 16-bit binary instructions and executes them.
The "Arithmetic Logic Unit" which drives me main logical operations of the Hack computer.
Every boolean and arithmetic building block of the machine.
The most primitive building block of the entire Hack computer.
Starting the Nand2Tetris journey, I knew little about the processes and hardware responsible for the technology I use every day. I was aware of the logic gates at the lowest level and how you can make simple chips, but I had never pieced all the parts together. The jump from understanding a single NAND gate to writing complex chips to creating a full computer and running a complete program on that computer had too many complex layers, so I never attempted to learn more than what I needed to. And honestly, that is the beautiful thing about programming and technology in general. Abstraction is an extremely powerful concept. The fact that I have been able to create all my websites and programs while knowing virtually nothing about the practical logic happening after pressing 'compile' is truly remarkable.
That being said, when I stumbled across Nand2Tetris I decided it was time to attempt to remove the magical cloud of mystery I held in my mind as the 'computer'. In just the first couple modules it was clear the course was thought out and planned with precision. The lectures combined with projects were perfectly crafted to break down complex topics and actually help you cement them with hands-on work. I went from creating NAND gates, to creating more and more complex chips, from MUX to a full RAM system to finally creating a full working CPU. From scratch! Then learning and creating machine programs and an assembler, on and on until finally creating a full programming language: Jack.
The most satisfying aspect of Nand2Tetris is the compounding nature of the course. Every module builds on the implementations and principles of the previous. You know you've literally built everything beforehand, but it reiterates the power of abstraction.
On paper, a course like Nand2Tetris may not seem to be relevant to high level developers, but coming out the other side I can confidently say it has sharpened the way I think and approach problems. I now have a far deeper appreciation for the technology I interact with every day.