After starting my new job at Boss Alien I’ve found myself less willing to program at home again. As a result I’ve turned back to other hobbies for the evenings, particularly electronics. I never had such a great understanding of the subject before now, but someone showed me the nand2tetris course, and I couldn’t help but give it a go.
My work on it is being archived here, although it’s likely not of any interest to people - if you find the course interesting you’d try it out for yourself, and (assuming you get the knack for it) you’ll be railroaded into largely the same answers.
Backing up briefly, the course takes you through the steps of designing a computer. You start with NAND gates, and use them to build more complex logical gates, and use them to build more complex ones, until you have a full CPU, with RAM and memory mapped input. Truthfully, the CPU the course tricks you into designing is much simpler than most modern general purpose CPUs, but it’s quite capable of running reasonable software.
Further, the course has you write an assembler for the CPU, and then a virtual machine, and a compiler for a simple programming language. The final product is a very confined but functional design for a computer, and the tools that one would need to work with it. Sadly physically building the CPU would be quite the endeavour of its own.
While reading about some part of the course I also came across a recommendation of the book Code which covers many of the same topics, while going down to a much lower level description of how to build the hardware, all the way down to wires, reeds, and electromagnets.
But could you build one by hand?
Ok, but should you?
Probably not, no. Ultimately, while the NAND gate is a convenient starting point for CPU construction in the modern day, you can do it with any number of other bases. The relay (a reed and electromagnet construction) can be used on its own, or in pairs or threes to make most simple gates (and some less simple ones like multiplexors). While you can make a relay by hand, it’ll likely be large and prone to breaking. Making enough of them for a CPU would be a very large time investment. If you purchased them instead, you’d find that compared to silicon gates, they’re slow and noisy and consume lots of power.
You might not be able to build a general purpose stored-program computer in a reasonable amount of time, but you might be able to build a specific-purpose computer.
I’m still deciding if I should give it a go.