Just finished the nand2tetris parts 1 and 2. I took this course for fun. It's an ambitious course that covers a lot of ground. Took me 3 1/2 months total. I wrote the HackAssembler, VMTranslator, and JackCompiler in java, on a Mac. My IDE was Netbeans. I had never written anything in java before, so that was fun.
I am aged in my fifties, and I have done a lot of high level programming over the years (decades!), including object oriented programming (Objective C), but had never had the pleasure of putting together logic gates into higher level chips, writing an assembler or virtual machine or compiler, or writing an OS class library. So plenty of new and challenging material for me, and I absolutely loved it. It was addictive and whenever I took a break I couldn't wait to resume. Both professors are excellent, and after the very last lecture, I still wanted more.
The course was extremely well designed, and they ease the burden by giving you guidelines, tips, test tools, and API's. This forum came in handy for me a few times. They also ease the burden by keeping things simple, e.g. the compiler could have been designed to allow for a richer Jack language, but that would bog us down and distract from the point of the course. I feel the professors found the right balance, with the exception of DFF (see below).
The NAND gate is given as a primitive, and while there was a short explanation as to how it works at the transistor level, it wasn't enough for me, but that's because this is not an electrical engineering course, so that's ok. I was able to move on without feeling a burning hole in my knowledge.
Moving along, the DFF (data flip flop) details were glossed over, but this was an instance where I felt I had to understand how it really works. After all, with an oscillating clock signal and a DFF, you can make a register store a value, which is nothing short of magic. I took a detour and studied flip flops on my own (using the Internet), and worked through using paper and pencil exactly how a positive edge triggered data flip flop would work through ticks and tocks (the two halves of a clock cycle), until I was completely satisfied, and it proved to be one of my most satisfying aha moments in the course, even it it wasn't specifically covered in the course. I drew on paper the NAND gates feeding back into themselves, and working through the timing diagram and truth table, I could see clearly how the Program Counter worked, how writing to memory worked, and how a program magically runs by fetching / executing an instruction and then fetching the next instruction, and so on.
The conclusion of nand2tetris part 1 is very satisfying, because before you realize it, you've constructed an entire CPU out of logic gates, and you have written an assembler.
The VMTranslator is a ton of fun, and full of aha moments because you see how the call stack works. They give you a lot of guidance on the implementation, which surely saves a lot of headaches. You also get to a point where you can bang out Hack assembly code with your eyes closed, as this project requires translating VM code to Hack Assembly.
The Compiler project was thankfully divided into 2 parts - the tokenizer, and the parser/code generator. The tokenizer turned out to be much easier than I thought (since I used regular expressions in java), and once you have that, it's not that daunting to finish the compiler's parser/code generator. Once the compiler works, it's incredibly satisfying. While a compiler is just another program, it is one of the most interesting software projects out there.
The last part, the OS class library, is very different, as you are suddenly doing a lot of Jack programming, and it's nice because you use your own compiler to compile and test it. I ended up adding some robust error checking to the compiler, which was also a fun side project. I particularly enjoyed implementing the heap memory management (alloc, deAlloc), and that really put things together for me, as once you understand the stack and the heap, it's an aha moment that gives you a much deeper understanding of what goes on under the covers.
The greatest thing about this course is the incredible work behind the scenes to break the course into manageable chunks. Honestly, it never felt overwhelming, and that's a huge testament to the course design and teaching style of the professors.
In the end, you have to pat yourself on the back, as you've learned logic gates, chip design, machine language, assembly language, virtual machine and the vm language, Jack language, not to mention you had to program logic gates in a HDL language, and you had to use Java or Python or whatever language you wanted to write an assembler, VM, and compiler. And you've learned how the call stack works, how complex expressions are parsed and compiled using a stack machine, and you've learned the details behind the stack and the heap. Finally, repeat to yourself - you have designed a CPU from scratch, written an assembler, virtual machine, compiler, and OS class library. It's nothing short of amazing.
First of all I'd like to thank you for the sweet summary of the course, it totally resembles with my experiences and saves me some typing.
Other than that I'd also like to thank the makers and maintainers. This course is nothing less than totally awesome.
I've just finished chapter 11 (JackCompiler) and the satisfaction has been overwhelming.
Since I've started coding in 2017 (I've started in my early 30s), I always wanted to know about the things that happen under the hood.
This course just nails this part and I feel so so much more comfortable in my daily developing tasks.
Btw. I'm developing on Mac and I've used RUST, which is probably my favorite language at the time of writing. But I don't know too much about the ins and outs of the language yet. So working through the projects really really helped to get a better understanding.
Just in case anyone is interested how that might look like, I've stored everything in my nand2tetris github-repo.
Also a great complementary resource to visualize nand2tetris part 1 is the nandgame by Olav Junker Kjær. Based on this first course he implemented a web-game around the concepts.
So thats it from me. I'm really looking forward to project 12 -> writing the OS.
RUST-NOTE (Submission Workaround):
RUST might not work out of the box for submissions on the nand2tetris Coursera course.
But I found a workaround in the coursera forum.
Basically it says:
- compile your code with linux as target (e.g. x86_64-unknown-linux-musl)
- write a tiny python program (with the name of the program e.g. JackCompiler.py), that calls your Rust-binary
- create a lang.txt for python (e.g python3)
- put all three files in your submission-zip