From a NAND Gate To Tetris
mikejuk writes "Long before the current crop of MOOCs (Massive Online Open Course) there was a course that taught you all you needed to know about computers by starting from the NAND gate and working its way up through the logic circuits needed for a computer, on to an assembler, a compiler, an operating system, and finally Tetris. Recently one of the creators of the course, Shimon Schocken, gave a TED talk explaining how it all happened and why it is still relevant today. Once you have seen what is on offer at http://www.nand2tetris.org/ you will probably decide that it is not only still relevant but the only way to really understand what computers are all about."
There's a circuit building platform which applies to this in the works:
http://www.circuits.io/
I watched this video and it really does seem like it would be a fun course! I'm not really sure about the whole God giving man NAND. Though that is prolly why my belief in God is 11. Hah, what a crappy NAND joke.
Somewhere between learning to write my first "Hello World" program on the Apple IIe (and the TI99/4A) and making a career out of programming years later, I went to schools for Computer Repair and Bio-Medical Electronics. I still have a pile of 7400 series IC chips and my breadboards amongst other electronic components. I learned analog and digital circuit design in the late 80's. The logic learned in those classes still applies to everyday programming today. No matter what I did in those previous careers, the training I did then still applies today. AND, OR, NOT, NAND, NOR, XOR and XNOR are still the 7 basic logic elements that make up all digital electronics and programming. From there Truth Tables are built and boolean algebra is applied to create any and all circuits and code today. In my humble opinion these are still essential to training people new to various IT fields. It's like having to learn nous, verbs, adverbs and adjectives in order to write understandable thoughts. If you lack this basic understanding learning the more advance concepts is difficult at best. It's good to see these are still being taught somewhere.
... but my god gave me nor gates and an endless world of blocks.
Looks great, much like I imagined studying Comp Sci ought to be. Ok one can get the book and use the materials for self-learning, but is there a list of institutions using the course for credit?
So many great courses and great teachers around now. Pity they didn't get all this together way back in my day. I've just been working my way through http://michaelnielsen.org/blog/quantum-computing-for-the-determined/ and am astonished at the simplicity and lucidity of Nielsen's teaching.
Well the thing is even today and decent university will require you to take at least 2 digital system designing courses for a CS degree.
I love this! I am a hardcore developer who's done assembly to Java. I have many non-technical friends who ask, "how does a computer work?" The short answer is that two electrical pulses, which we call either 0 or 1, go through something (a gate like NAND) to get an output of 0 or 1, and you combine that in a massive logic puzzle to get a computer. This course describes everything in detail. Love it. Well, not "everything" but certainly everything non-educated but technical people want to know.
Just because the U.S. is a republic does not mean it is not a democracy. Democracy/republic are not mutually exclusive.
Quite tough to align multiple NAND gates without open spaces between them. With one circular and three flat faces it doesn't fit well. Oww and that annoying circle for the inverter... Happy that I live in Europe: Though I dislike our (square) logic gate symbols, they are great for tetris... http://en.wikipedia.org/wiki/Logic_gate#Symbols.
See: we Europeans beat the USA even with logic gate-tetris !
I agree with the bottom up approach to learning programming & CS.
I started off learning BASIC, but it was very slow going. As soon as I got into 8086 Assembly everything clicked into place. After making a few simple games, I built my own Boot loaders and toy OSs, Languages, etc. without any teaching or courses needed. I remember thinking, "I wonder how you make a bootable disk?", Turns out everything I needed to know was in the BIOS documentation: Interrupt 19
I agree that knowing about the circuitry was neat, and necessary for completeness, but it's by no means essential for CS, IMO. Learning the electronics didn't really help me much because at the instruction level even things like CALL are abstractions for more logic... Maybe if I had been learning on RISC hardware, or had been content to stay in some VM Sandbox I'd have a different view?
The difference between the NAND to Tetris course, and taking a crash course on (x86 | ARM) Assembly + RTFM for your BIOS and CPU is in the end, my programs actually worked on Real hardware. That makes my efforts far more useful immediately and far more relevant. For instance, I built disk partition tools and undelete utilities and actually sold them on a BBS I built myself, and I still use them to this day. I've got a .ISO with my OS and disk tools, and some games that I can put on Floppies, HDs, USB drives, CDs / DVDs, etc. and boot them with any x86 or x64 system.
I understand the course is for Universities, and so contains a certain level of depth, but IMO, after you study how NANDs can perform computations they should switch to ARM or x86 assembly using Real hardware -- A Raspberry PI costs less than their damn physical book!
Furthermore, NANDs alone do not a computer make. That's just WRONG. You need something to pulse the logic gates, like a Capacitor. If you want it to be actually useful then it'll need I/O: You'll need some buttons and a display. If you're not going to teach CS then why focus on the irrelevant underlying circuitry to such a large degree? When I was 18 I actually wired transistors, capacitors, resistors, LEDs and button switches together to "Program" an actual working Tetris game -- Didn't require a VM to run, and my friends were far more impressed than they would have been with some program inside an existing computer.
My point is: Don't preach building computers from scratch unless you're actually going to enable folks to do just that in real life. If it's a CS course then utilize an actual chipset. IMHO, Save time & download (QEMU | VMWare) + (GNU Assembler | NASM) then start building your own bootstrap loader that will run on real hardware.
I haven't taken this particular course, but the "Introduction to Computer Design" course at my university, where we started with AND and OR gates, and ended by building a simple microprocessor, was definitely one of my favorites. It definitely had the feeling of magic: you figure out what you want to do, put together a bunch of random bits of logic, draw a box around it, and suddenly you've got an adder or an instruction decoder. I still feel that way whenever I write a really new bit of funcitonality.
TCP: Why the Internet is full of SYN.
I'm not saying its a good idea to develop an elitist attitude towards the people that use them, but this explains why there's some rational basis for looking down on scripting languages. It's not that they are inherently bad or that the people who use them lack the ability to do 'real programming'. But, they are basically all about not having to know anything at all about how the other layers of abstraction work, and a consequence is they also don't give the programmer any real connection to how the hardware layer works and how you get from it to what they know.
For example, if you know how an OS is generally compiled in a language such as C or C++, then the next step is understanding that the compiler is itself running 'on a level above' assembly language. Understand that, and its a straightforward conclusion that a program can always be written in assembly that bypasses ANY controls the OS has about accessing different parts of memory, doing file copying, assigning user and admin permissions, and similar things. That program may be much less portable than something written in Perl, but it's inherently very powerful at what it does. It's not that people who program in assembly are necessarily any smarter or better at it than people who write Python. That's certainly debatable. The thing that isn't debatable is that the closer a programmer gets to machine language, the more they can do that nothing higher in the heirarchy can stop, position itself against, or even detect. At some point, that means trying to secure scripted code, or compiled code, or anything above assembly is like trying to defend a point with what may be a perfectly good machine gun, but the other side is the only one with stealthed, antimatter pumped, orbital X-ray laser arrays. They can have sloppy aim, lack elegance and inspiration, and still win.
Nowdays, there are plenty of people working with a modern OS, even one that is still all compiled at just one level above assembly (if there are any real systems that you want to count as modern that still fit that, what with silverlight, dotnet, flash and so on on just about every machine out there), who don't understand the heirarchial nature of coding worth a damn. It seems to get worse as you get to people writng applications for the various OSes. Some of these people are very good coders (or scripters, or whatever), but they really just can't write secure apps, because they don't really understand what the difference between a script kiddee attacker and a threat whole governments wish they could get on their side really is.
That's just one of the things this course and others like it are supposed to fix. A lot of us need this. Hell, I've known this stuff for 35-40 years, and this reminds me I should get out the old books and do a little refresher. If you've read things about coding becoming as professional as aero-space engineering or similar, and found yourself agreeing with any of them, this is where it starts.
Who is John Cabal?
This speech at TED was featured in my local Linux User Group based in South India a few weeks back. I am planning on conducting this course for my College students in CS and IT branches.
The video also features Pramode CE who runs a consultancy for Embedded Systems and Software in nearby Trichur in Kerala State.
Very nice course, one I fully recommend for all ages.
If you keep throwing chairs, one day you'll break windows....
in Minecraft.
Anyone else first read that as NAND2Tardis?
Need coffee
I did all the projects carefully, and the book blew my mind. It is today my favorite textbook in any subject, and I don't even focus on computer science. It was so enlightening and so fun. I know how to make a computer now.
This was given as a course in my University (the Hebrew University in Jerusalem) eight years ago in which the lecturer was the other creator (Prof. Noam Nissan).
I think the beauty of it is the fact that you manage to understand the principles of each level of the architecture without going into deep depth of each one, and so it manages to remain interesting throughout the course.
At the end of the course, we ended up writing xonix (which involved writing a non-recursive flood-fill algorithm).
Some team even wrote Socoban.
Although MIT started at the transistor level when I took it, and it was two courses. The only big drawback was their insistence on spending time on LISP, which was very exciting to computer scientists and taught *horrible* habits of excessive recursion and drawing "levels of abstraction" related to modern "object oriented" practices which continue to cripple computer performance worldwide.
I'm heavily into teaching and computer science so I'm always looking into this kind of stuff. I came across this book and worked my way through all the exercises.
I love this book/course so much that I'm looking for a place that'll allow me to teach this course. Salary not required. But it's all dot-net and stuff around here. Lamers.
TCAP-Abort
After 50 years messing with computers, including being there when the Illiac sang Daisy..., I am of the view that some problems that were present day one are still with us -- despite thousands of name changes, redefinitions and similar marketing hype. And too many repetitions of 'oh, thats obsolete... you really should be using...'. And some salesfolks will tell your boss that about you when you are not cooperating with their personal profit plan. Anyhow, since day one through until today everything has to be stored someplace, and all sharing schemes are really just slight of hand -- computers don't share anything (but have gotten very good at pretending). Nice to see timesharing coming back -- although I believe that the term 'cloud' probably best applies to the marketing around it. Besides, its pretty meaningless if local connectivity is poor. And personally, I am not so sure that the thousands of programing 'languages' have done much good beyond pushing people out of the industry and making it easier for HR to hire the one with the .... Has certainly made it harder to learn from experience. But it is nice to see someone talking about the importance of understanding how it all comes together -- a pity it seems to be a minority view.
Same concept, written by Charles Petzold in 1999:
http://www.amazon.com/Code-Language-Computer-Hardware-Software/dp/0735611319
The NAND gate is a pretty high level abstraction of the quantum mechanics taking place within the semiconductor junctions. Maybe start with vacuum tubes, since those are a much simpler implementation of NAND...
Tanenbaum's Structured Computer Organization takes a similar approach, going from the boolean logic of a transistor gate up to the OS and application level. I took a class with the first edition of Tanenbaum's book as the text in 1983 and l learned more about computers from it than from any other class before or since.
"If you're not passionate about your operating system, you're married to the wrong one."
Slide 4 on the intro is wrong, Pong came out in the early 70's, in the 80's we had the Z80 and the Motorola 68000 in most of our arcade games. http://www.nand2tetris.org/lectures/PDF/lecture%2000%20introduction.pdf
Coincidentally I have been running through this course in my spare time and I have to say it is the best I have found in 10 years. I've been itching to build a homebrew cpu like http://www.homebrewcpu.com/ but lacked the basic skills to design a proper ALU and such. Most other courses either start way too basic and then shoot too far forward or they gloss over the basics and go right in to advanced concepts. So far I have made it through Chapter 2 and I'm proud to say that I've built all the basic components in HDL without looking anything up outside of the course material. Being able to build complex components on top of basic components I built myself is very rewarding. This is a must take course if you want a more intimate understanding of how computers work. And if building a computer from basic gates isn't nerdy enough for you, build your own transistors.
I agree with the bottom up approach to learning programming & CS.
This is not necessarily a "bottom up" approach. Digital logic winds up being pretty important to know for writing very high level programs -- secure multiparty computation, model checking and formal verification systems, automated theorem proving, and so forth. This is not a stack, it is a cycle.
Palm trees and 8
I think it makes more sense to start with the "transistor is a switch" level of abstraction. Make some logic gates out of transistors and then go from there. Most people have heard that "computers are made out of transistors" and have probably always wondered where exactly they fit in.
One could try to start even lower, and introduce some basic semiconductor physics--but I'm not sure of a clean of way of introducing those concepts without lying a lot.
Sometimes we need to step back a few paces to ask exactly what it is that we're trying to accomplish. When a teen-ager is ready to learn to drive, it is not essential for him/her to be able to rebuild the engine or put in new piston rings. After a person has an introductory-level understanding of what an automobile does, then he/she may want to explore the details in greater depth. Some people may actually turn out to be more interested in painting the car in different colors, or using it to transport sick people to the hospital. We need to be careful, I suspect, not to overwhelm the new computer student with a lot more than the student has to know _at that stage in his development_ ... there needs to be a few (well supervised) joy rides in there to keep up interest. To be sure, the new student does not know enough to know " what he needs to know." But the level of study should be an outgrowth of the person's real interests.
What would Alexey Pajitnov and Henk Rogers think about this? Their company successfully sued the publisher of an unlicensed Tetris clone for copyright infringement a few months ago.
. . .the only way to really understand what computers are all about.
Really? The ONLY way?
With a name like Schocken, it *HAS* to be an excellent electronics course.
Nyark nyark nyark.
I looked at the "Getting Started With Digital Logic - Logic Gates" part. Anybody who has actually built something with TTL on a breadboard should know that 7400 series gates can sink a lot more current than they can source. Connecting a logic output to ground through a LED may not draw enough current to turn the LED on fully. The right way to do it is to connect the LED between the logic output and the Vcc rail in a pull-down configuration (with a current limiting resistor). Of course, that gives you inverted logic (LED on means logic 0, LED off means logic 1), but you get used to that. If it bothers you, use an inverter.
The recommendation is to wire three NAND gates back-to-back. One NOT gate wired to itself can get stuck whereas three NAND gates are always in conflict and this keeps the circuit oscillating.