In this project-centered course you will build a modern software hierarchy, designed to enable the translation and execution of object-based, high-level languages on a bare-bone computer hardware platform. In particular, you will implement a virtual machine and a compiler for a simple, Java-like programming language, and you will develop a basic operating system that closes gaps between the high-level language and the underlying hardware platform. In the process, you will gain a deep, hands-on understanding of numerous topics in applied computer science, e.g. stack processing, parsing, code generation, and classical algorithms and data structures for memory management, vector graphics, input-output handling, and various other topics that lie at the very core of every modern computer system.
This is a self-contained course: all the knowledge necessary to succeed in the course and build the various systems will be given as part of the learning experience. The only prerequisite is knowledge of programming at the level acquired in introduction to computer science courses. All the software tools and materials that are necessary to complete the course will be supplied freely after you enrol in the course.
This course is accompanied by the textbook "The Elements of Computing Systems" (Nisan and Schocken, MIT Press). While not required for taking the course, the book provides a convenient coverage of all the course topics. The book is available in either hardcopy or ebook form, and MIT Press is offering a 30% discount off the cover price by using the discount code MNTT30 at https://mitpress.mit.edu/books/elements-computing-systems.
The course consists of six modules, each comprising a series of video lectures, and a project. You will need about 2-3 hours to watch each module's lectures, and about 15 hours to complete each one of the six projects. The course can be completed in six weeks, but you are welcome to take it at your own pace. You can watch a TED talk about this course by Googling "nand2tetris TED talk".
*About Project-Centered Courses: Project-centered courses are designed to help you complete a personally meaningful real-world project, with your instructor and a community of learners with similar goals providing guidance and suggestions along the way. By actively applying new concepts as you learn, you’ll master the course content more efficiently; you’ll also get a head start on using the skills you gain to make positive changes in your life and career. When you complete the course, you’ll have a finished project that you’ll be proud to use and share.

教学方

Shimon Schocken

Professor

脚本

Welcome to Nand to Tetris part two. Nand to Tetris is the name of a computer science educational adventure, in which we build a complete, modern, general-purpose computer system, hardware and software, from the ground up. Because this is quite a substantial journey of discovery, we decided to split it into two separate and stand-alone courses. In the first course, which in Coursera is simply called Nand to Tetris, we start with the most elementary and sort of primitive logic gate conceivable called Nand, and using a series of 600 construction projects, we build a computer platform which we call Hack. And then in the second course, in Nand to Tetris part two in this course, we start with the Hack platform as a point of departure and then we build on top of it a virtual machine, a compiler, an operating system and all the systems which are necessary so that we'll be able to write high level object-based programs on this barebone hardware. That's what we do in the second part of the Nand to Tetris journey. The creators of Nand to Tetris are Professor Noam Nisan, who works at the Hebrew University of Jerusalem, and myself. My name is Shimon Schocken. I work at the IDC Herzliya. And as you see from these pictures, both Noam and I enjoy getting into and playing with the most elementary and fundamental building blocks of applied computer science. And I must tell you that the deeper we look into computer science and mathematics for this matter, the more beauty that we discover. And as you take the Nand to Tetris courses, you will share with us exactly the same profound feeling. So, here is the big picture of Nand to Tetris. And what we see here are the two end points of our journey. At the bottom, we see the barebone hardware, which is capable of nothing more than detecting between two different signals, zeros and ones, and processing these signals in remarkably clever ways. And at the top of the journey, we see some human high level programmer or an entrepreneur, who have all sorts of lofty thoughts and fantasies about developing computer games, and search engines, and airline reservation systems and what not. And the question of course is how do you bridge the gap between the abstract thoughts of the high level programmer and the barebone hardware that can do nothing more than process zeros and ones? Well, bridging this gap is what Nand to Tetris is all about. And as you see, we do it in several different, well-defined stages. And each of one of these stages entails one or more programming projects. And once again, we split it into two different courses. So, in Nand to Tetris part one, also called simply Nand to Tetris in Coursera, we begin with many instances of the Nand generic gate. And using these gates, we build some elementary logic gates like and, or, not, so, multiplexes and so on. Then we put these gates together and we build memory systems, ALU, CPU and the entire Hack chipset. Then we assemble these chips together and we create what is known as a classical von Neumann hardware architecture. And we end this course with writing an assembler for this particular computer. And so, at the end of this process, voila. We have a computer, which we call Hack. Now, at this point, Nand to Tetris part two kicks in. And in this course, we treat the Hack computer platform as an abstraction. We don't care about questions like how the CPU was constructed? And how registers are built from lower level data flip flops. We don't care about all these details because we have a computer, which for us is a black box obstruction, and we are going to interact with this computer through its interface, which is machine language. But actually, it's more convenient to think about the second part of this course top down. So let's shift our attention to the left side of the screen and focus on what happens in the process of writing high level programs. And this, by the way, is exactly what you guys do when you write programs in Java, or Python, or C#. You don't care about all the other parts of the computer, you just focus on the high level programming task. Now, in Nand to Tetris part two, we're going to introduce a high level language called Jack, which is a simple version of Java and Python, C#. And it's a language that if you know any one of the languages that I just mentioned, you can learn it in something like one hour of learning, and then you can write very nice programs in the Jack language. Let me show you some examples of programs that our students have written in previous versions of this course. So here is a program in which we play Pong, and that's a program that the student brought in order to teach typing skills in an interactive and engaging computer game. Here is Space Invaders. Here is Sacoban, a famous game that came from Japan. Here is Bouncing Ball with very nice animation. And here is RAWR game. And of course, many students developed all sorts of versions of Tetris. By now, thousands of students have taken these courses and therefore, there are many examples of cool Jack programs out there. And here is one program that I wrote. And in this program, we see some two-dimensional points. And the program constructs these points and manipulates them using all sorts of algebraic manipulations. So let's take a look at this program. What we see here is the Jack code that actually generated some of the output that you see in front of you. It begins with a class called Point, which implements the two-dimensional point functionality. And then we have another class called Main that uses the services of the Point class in order to create and manipulate some points on the screen. So that's how the Jack code looks like. And I think that you will agree with me that it looks very similar to other languages like Java and Python. And in fact, in the third week of this course, you guys are going to write some programs like this one, using Jack, and we want you to do it in order to get the feeling of the language for which you will have to develop a compiler later on in the course. In particular, as you know, when you want to execute a program that you wrote, the first thing that you have to do is compile it. So here is our compiler. And just like other compilers like those of Java and C# and to a certain extent Python, our compiler does not translate the source code directly into machine language but rather it translates your source code into an intermediate a language called VM code, which is designed to run on an abstract virtual machine. Now, it goes without saying that I don't expect you guys to understand any of the details of what you see here and we're going to give you all the necessary background and all the techniques which are required throughout the course. At this level I just want you to get the spirit of what's going on. So, here is how the compiler works, it goes through your source code and if you focus on one particular command for example, the command that creates a new point where the coordinates x = 1 and y = 2 and stores the address of this object in a in p1. Well, this code is going to be translated by the compiler into four VM commands as you see at the right-hand side of the screen. Now you guys are going to write this compiler, under our guidance of course, in weeks four and five of this course. Now, the resulting code that you see here, which is very similar to what is known as Java byte code. Also similar to what is known as IEL in the world of Doc net and the C sharp. Well, this code is also an obstruction, it is designed to run on some imaginary computer, a virtual machine. In order to make this obstruction concrete we have to translate this code further in to machine language and the machine language that we're going to use is the native code of the Hecht computer. And you see it here in front of you, this is Hecht assembly language. So here's an example of how this VM translator works. It takes, let's say the first command in your VM program, which is a push 1, a typical stack-oriented Command and once again we'll discuss all this stuff in the course. I don't expect you to even know what a stack is. But it takes the first push command and translates it into what comes out as seven or eight different machine level instructions. And once we have these instructions generated, we can load them into the computer and finally the program will start executing. So that's what you guys are going to do in the first two weeks of the course. You will develop a VM translator which is quite similar to Java's JVM and to Microsoft CLR, everything that we do in this course follows the modern paradigms of software engineering, and let's you guys to sort of get into the most important ideas behind every one of these tools. Now there's one piece which is missing in this puzzle, and this is the operating system. Because you see, you cannot write high level language these days without using the services of a host operating system. Because there are so many things we have to handle. Graphics, animation, reading input from the keyboard, managing your objects in memory. Who's going to do all these things? You? There's no way we can require high level programmers that have so many problems of their own to take care of all these integrated details. For this we use an Operating system. So in week 6 of the course we're going to develop exactly such basic operating system under our guidance. So here again is the big picture of Nand to Tetris Part II with the project laid out on the roadmap. And many people ask us how can you possibly cover so much material and build so many important fundamental systems in applied computer system and applied computer science, excuse me. In no more than six or seven weeks of instruction. Well, we have a secret sauce. And the secret sauce is our course methodology. In particular, you have to understand that first of all, we are going to teach you all the necessary computer science knowledge which is necessary. In order to build all the systems which are described in this course. You don't have to bring from home any previous knowledge except for some basic programming skills. We'll provide all the necessary algorithms, data structures, programming tricks and hacks and so on. Also we're going to provide you with some very useful software tools that will make your life easy. For example, before we ask you to implement the future machine yourself, we will give you a VM simulator that will enable you to play with an animated virtual machine and understand exactly what has to be done in the actual project that you have to develop. Also in this course, Norm and I are going to play the role of the system architects and you guys are going to be the software developers who actually implement the specifications that you get from us. So we're going to supply you with elaborate and well-explained APIs and blueprints and design documents. And so there will be no uncertainty and confusion whatsoever. You will know exactly what you have to do. To the letter. And in addition with all these design documents, we're going to also provide you with a huge pile of test programs and test files and test scripts so that you'll be able to test your work, or I should say you need to test what you do in a very low resolution. Something like every ten or 15 lines of code will have a test that you will be able to apply to what you wrote and convince yourself that what you've done is good and that you can continue to go to the next stage in the development. And the most important feature of our course methodology is that the course is a lot of fun. It is thrilling to build a computer from the ground up, and you're going to enjoy it tremendously. And I must say that by now thousands, if not tens of thousands of people and self learners and students have already taken Nand to Tetris courses and with very few exceptions all of these guys are very happy campers. And so that's the big picture of Nand to Tetris Part II and the course methodology. The course is going to last seven weeks, and in every one of these weeks, we're going to have a set of video lectures that will take you something like three hours to view. Then you will also have a project, that programming project that you have to implement and there is also a book chapter that you are welcome to read but it is not required. The textbook that accompany this course was written by Norman and myself, it was published by MIT Press And it's an optional reading. If you want, you can use it, but you don't have to. Altogether, the weekly workload is going to be something between 10 to 20 hours of work, depending on which week we're in. And I must say that the word week is somewhat weak, W-E-A-K. In the sense that if you want your week to last 10 days or 14 days, that's perfectly okay with us. You should work on these projects at your own pace. And you are the captain of this ship. We just give you some guidelines, but you decide exactly how you want to drive it. And you will need some self-discipline and try to complete these projects within the course schedule. But once again, if you slip, that's fine with us. The most important thing is to complete the project and learn the underlying ideas and techniques. The prerequisites of this course are quite minimal. We expect that you have some programming ability, st the level which is acquired in typical Introduction to Computer Science courses. So you have know either Java or Python. You have to know the basic techniques and skills of object-oriented programming. If you have this basic knowledge, then you're welcome to take Nand to Tetris Part II. It is also recommended, but certainly not required, that you will take Nand to Tetris Part I. In fact, the two courses are so independent of each other that you can take them in reverse order, if you will. But of course we recommend that you take part one first, part two second. But once again, you don't have to. You can start from scratch with the Nand to Tetris Part II. Now, in closing, I made a list of some of the topics that are going to be covered In this course. And it's quite, I think, mind-boggling to see how many subjects we're going to visit in Nand to Tetris Part II. And the exciting thing about this longer list here is that we are not going to wave our hands too much about any one of these concepts. We will explain them, of course. There will be no, as I said, no uncertainty and no confusion. But every item that you see in this list is something that you will learn hands-on. Because it will come up in the context of building a system, something that you are going to do with your own hands. So this, in a nutshell, is the contents of, once again, most of the contents of this course. And as you go through this course, you will become a significantly more sophisticated, enlightened, and confident software developer. Because, you see, right now, I assume that you may have some very good high-level programming skills. But you have all sorts of doubts, and some uneasy feelings about how the compiler works, what exactly is the virtual machine, how my program interacts with the operating system, and how all this gestalt works together. Well, Nand to Tetris sheds light on all these questions,. And as you'll get this knowledge, once again, you become a much more sophisticated developer. In addition, you will be exposed to numerous, or I should say, the most important ideas and techniques in applied computer science. And finally, you will become a richer person. Not necessarily financially richer, although I think that this course will certainly contribute to your career prospects. You will become richer intellectually, because, through this course, you will connect to the soul of the machine. You will connect to the soul of the most important machine that mankind has built, at least in modern times. And connecting to the soul of this machine is what Nand to Tetris is all about. So thank you for sitting patiently through this course overview. And the next thing that we'll do is discuss Project 0.