The Joy of Nand2Tetris
tristanrhodes.comHaving done nand2tetris before doing various digital logic courses, I feel like the first portion falls a little short of its tagline of making a computer from modern first principles. It focuses too much on the specific implementation of its own architecture rather than giving the tools needed to create the architecture from scratch.
It doesn’t teach things such as product of sums and kmaps which allows you to methodically find the Boolean equation for any arbitrary output. I spent most of my time during the architecture implementation finding the correct expressions, while it becomes trivial if you learn how to do it systematically.
It’s lacking in teaching how state works, mostly because it passes over flipflops and their applications. It also doesn’t teach finite state machines (FSM), which was the single most important thing for me in understanding how to actually implement an architecture. This is because the concept of FSMs abstracts most of the logic and focuses on the behavior, and once you design the behavior you can then methodically implement the logic with the previously mentioned techniques.
> It doesn’t teach things such as product of sums and kmaps which allows you to methodically find the Boolean equation for any arbitrary output
This is useful beyond low-level work. Every now and then I review code where the author has a complicated boolean condition (often in combination with auth and caching) and there's a much simpler way to write it -- that also has a more intuitive interpretation!
The same thing goes for finite state machines, of course, but the refactorings suggested are often trickier to apply in a late-stage code review.
These things used to be the basis of CS education 20 years ago. Are they not today?
Why do you assume that OP has a computer science degree?
IT has always been a sector where you can have a degreeless career. Moreover, plenty of IT degrees are not computer science (data science degrees, to take a popular example)
I did a bachelors degree in Electronics and Communication engineering. It was standard to watch things go from a diode, to transistor, to a flip flop, to a register, then 8/16/32 bit adders- Once here subtraction is just addition in 2's compliment. Multiplication is repeated addition, and division being repeated subtraction.
After this you immediately go and learn 8085, and then 8086
Pretty sure they are not anymore, when I was majoring in cs the deepest I was taught was assembly and architecture at a high level. I then switched to computer engineering and that’s where digital logic was a mandatory class.
Do you have a recommendation for a book or course that teaches these things better? In particular FSMs.
Structure and interpretation of computer programs is a better nand2tertis. The issue is that it contains about 10x the information, assumes what an undergrad science student in 1980 would have known, has problems that are entire chapters of nand2tertis and uses scheme.
And it's not until the end of the last chapter that you build a stack machine in about 40 pages from memory.
I can't see how SICP is better than Nand2Tetris. To be clear: none of them are better than the other simply because these are two completely different books, both in their approach style how explain things and their contents. You are basically comparing apples to oranges. If you know nothing about computers Nand2Tetris and Code by Charles Petzold are two books that will make you clearly understand how a computer works in a constructively way. SICP starts with an already running Scheme, so the computer and the language are already there.
Read chapter 5 of SICP.
Whenever I talk to people who rave about SICP I get the feeling they never made it to chapter 4 and beyond.
> In this chapter we will describe processes in terms of the step-by-step operation of a traditional computer. Such a computer, or register machine, sequentially executes instructions that manipulate the contents of a fixed set of storage elements called registers. A typical register-machine instruction applies a primitive operation to the contents of some registers and assigns the result to another register. Our descriptions of processes executed by register machines will look very much like ``machine-language'' programs for traditional computers.
https://mitp-content-server.mit.edu/books/content/sectbyfn/b...
The transistor level simulation happens in 3.3.4 "A Simulator for Digital Circuits".
Soo, maybe go nand2tetris and then SICP?
I really liked this book https://www.goodreads.com/en/book/show/2558730.Digital_Desig...
It teaches the basics and then how to build a MIPS processor.
I know that's only part of what nand 2 tetris aims for. But still good.
I would really recommend Digital Design and Computer Architecture, I’ve got the ARM edition. I believe it covers everything OP mentioned, and I know it covers FSMs. It’s a great read if you want the tools to design your own architectures.
This Youtube channel has amazing explanations, starting with:
How Transistors Run Code?
there is “switching theory and finite automata” by zvi-kohavi, one of my prized possessions from an era long past.
I can't recommend nand2tetris highly enough – it's a great crash course in computer architecture, operating systems, compilers, etc. but also it's just mega fun.
A big part of the joy came from making up my own extra credit side quests: implementing a compile-to-WASM emulator for the hack machine, adding optimisations to the compiler to produce smaller and/or faster programs, etc.
Ooh, I also did the compile-to-WASM side quest! There are some really fun optimizations one can do to make the emulation run faster.
It's orders of magnitude faster than my naive hand-written emulator.
There's a gamified version of nand2tetris available on Steam called "Turing Complete" (https://turingcomplete.game).
I completed it up until the assembler challenges, and I felt the same way as the author. Granted I knew Kmaps, etc. from my uni days, but given the nand2tetris book you might be able to figure it out.
That game is early access but hasn't been updated for 2 years so is probably going to stay that way. Is it compete enough?
Quite. I had a great Christmas break a couple years back going through all the missions. It has some edges to it but people have also implemented things like RISC-V in it so it's also quite complete. The game portion is enough for fun and exploration.
I got all the way to the final missions where you're writing your own assembly (that you created) to solve various programming puzzles. Only stopped because I got busy with something else and break was over. I def recommend it. Reminded me at the time of Code by Charles Petzold but applied.
(Last I checked the Author was rewriting much of it for performance reasons and to fix up a few gotchas that should be possible with circuits but aren't here - no idea if they still are but that was my understanding before)
The game has an alpha version appropriately named save_breaker that gets regular if not daily updates. Some of the later puzzles are completely different, the second architecture has been replaced with a more advanced one that includes pipelining, and some new puzzles are still in the works. The new assembler is much more modular and many of the components have changed shape, with some having been removed or combined. The author plans to release it as v1 when stable but who knows when that will be. Breaking changes still occur occasionally.
IMO, yes it is complete enough (note: I only went as far as the assembler challenges, I'd done enough assembler beforehand). But I did build a general purpose computer from NAND gates up.
Development still appears to be ongoing on Discord, which is quite active. I think the dev may have bitten off more than they could chew with their last patch promise: https://www.youtube.com/watch?v=38cKko7sViw
Yeah, not having any updates in 2 years for a performance rewrite is brutal. They haven't even posted news on Steam in over a year.
Hopefully the traffic uptick from this will convince them they need to at least post a notice talking about what's going on with development.
It's complete enough, yes. I played it up until the "main quest" was done (building a TC machine). It took approx. 20 hours and I loved it in a very similar way as the blog post author describes Nand2Tetris, so I'll have to look this one up too.
I bought it to revise my intro to computer engineering course before the exam and it worked pretty well for that. Didn't hit any bugs and it also was content complete as far as I could tell
> There's a gamified version of nand2tetris available on Steam called "Turing Complete" (https://turingcomplete.game).
Also have a look at MHRD, which is to my knowledge even more inspired by nand2tetris.
Many years ago I worked through The Elements of Computing Systems. It was the single most impactful experience in my computer learning journey. The book and exercises are a rare piece of pedagogical genius I am grateful to have encountered.
You too can build a(n emulated) computer from scratch, and I can't recommend it highly enough.
I've wanted to do Nand2Tetris for a very long time, but it just never reaches the top of the pile of "things I'd like to do".
Many years ago I built a linux system following the Linux From Scratch (LFS) guide. My experience doing it corresponds with a lot of what the author mentions.
In all this there is a slightly uncomfortable realization, at some point you need to trust the layers below, knowing everything is simply not possible.
As someone who didn't follow the conventional path into software engineering via a CS degree, Nand2Tetris has helped fill in a lot of gaps in my knowledge.
I completed part 1 of Nand2Tetris in 2023 and this year I'm working my way through part 2 where you write a compiler and OS for the architecture that you built in part 1. It feels great to finally start understanding concepts like memory management, virtual machines and compilers.
Around 2001 I started my journey to becoming a software developer, and the first thing I really wanted to do was get a better understanding of what a computer is and does.
I stumbled upon and Nand2Tetris, and I'll be upfront and say that I found it to be a little dry and I was being honest to myself, it beyond what I was ready for.
However, it was still instrumental to helping me develop my understanding of computers. Instead of following the course normally, I decided to transfer the concepts and lessons learned and created a rudimentary computer in Minecraft. It transferred the project from a n abstract thing I struggled with to a "physical" engineering project that made the CS ideas real and tangible things that could be interacted and experimented with.
I highly recommend it to anyone.
I should like to go back and finish it, both the course and the Minecraft project(I only did part 1).
Both the course and the book are phenomenal. In my opinion they are up there as one of the best CS resources. I finished it two years ago and still think about it fairly often.
The compiler exercise is beyond excellent and cracking it feels like a milestone.
Yes, this is the book. Do all the exercises without cheating and you emerge as a much stronger engineer.
I’ve just started the course and am considering paying for the Coursera certification to help keep me on track. Does anybody have insights into using Coursera as opposed to using the freely available resources?
Author here. I just used a free pdf version of the book and the legacy software package which they link to on the website. Great experience. The authors have since created a self-contained web IDE version of the book/course, but if you know the basics of working with a terminal, you'd probably prefer the software package.
I’m interested in this. What it the best way to learn the material? The book? The coursera course? Both? It’s a bit hard to tell just from the website.
I've been following the website and the course material provided therein: https://www.nand2tetris.org/course I did not sign up for the course on Coursera because I was able to make progress just fine with the free material on the website and I did not want to pay Coursera to get their certificates of completion.
The first 6 projects do not require purchasing the textbook as the relevant chapters are provided along with the project material. The next projects do not have the textbook chapters provided, so I bought the textbook.
I'm currently working on Project 8. I've been blogging about my progress here, if you want to take a look: https://gurudas.dev/tag/nand2tetris/
the nand2tetris book, Ben Eater's tutorials and nandgame
For me, NandGame[1] is a far better way to go. You get a much better hands-on feel of things when you can toggle the inputs yourself, and see how things work.
Is there some better simulator I can download to run the assignments from? I don’t like the Java and the online version they provide.
Recommend this to people that are curious and have time!! I really enjoyed doing it years ago
N