Book Review: The Elements of Computing Systems

I do not fear computers. I fear the lack of them.
– Isaac Asimov


Computer programming is a passionate hobby for me from my school days. But I ended up taking a degree in electrical engineering. Almost everything I know about computing is self learnt. This is true for a lot of programmers out there. Most of us are proficient in one or more computer languages and are familiar with the technology stack we use in our day to day work. Yet most of us also have a nagging feeling that we don’t know fully how computers work!

Interestingly this is a problem faced even by computer science graduates! This is due to the high level of specialization and separation of computer science topics. Hence even CS graduates miss the elegant big picture of the computing field. The Elements of Computing Systems is a book designed to address this gap. This book attempts to provide a complete high level summary of the computing basics in just about 250 pages! Man, it does a really good job at that!

As you go through each chapter in the book, you are required to build each building block of a computer. You start with the basic Boolean logic gates and then move onto building complex Boolean circuits, Arithmetic & Logic Unit (ALU), CPU, memory modules, machine language, assembler, virtual machine, high level language, compiler and finally even an operating system!

Book Review: The Elements of Computing Systems

The Elements of Computing Systems (also known as Nand2Tetris) is written by two computer science professors, Noam Nisan and Shimon Schocken. It is a self study guide for building a modern computer from first principles. The book’s basic premise is that the best way to understand how computers work is to build one from scratch! The book consists of 13 chapters each containing a project that the reader is supposed to solve. The only pre-requisite for the book is the knowledge of a programming language.

If you study the book and then solve all the programming problems in it, you will get a deep understanding of the following topics,

  • Boolean logic and logic design
  • Data representation in computers
  • Designing memory, ALU and CPU
  • Practical use of data structures & algorithms such as stack, list, recursion etc.
  • Method call stack, object allocation and heap
  • Variable types, scope, object and array representation
  • Memory addressing and memory mapped I/O
  • How to write an assembler, virtual machine, compiler and operating system!

Obviously building a full fledged computer from basic logic gates is a very complex undertaking. However the authors have simplified this challenge substantially by adopting a number of clever strategies. These strategies ensure that the programming problems doesn’t become too complex for a beginner,

  • We use a hardware simulator for building computer hardware. This avoids the need for working with physical components. Yet at the same time this teaches you everything you need to know about hardware!
  • This course ignore error handling and optimization problems. For example, when you write a compiler you can assume that the program being compiled is error free. Optimization is an important yet hard problem. Ignoring it makes things simpler.
  • The ALU (Arithmetic and Logic Unit) and CPU built as part of this course has a very simple instruction set. For example, the CPU we build won’t have any native multiplication capability. Also it only works with 16-bit integers.
  • The assembly language and high level language (Jack) are all a bit verbose. But this substantially reduces the complexity in building assembler, VM code generator and compiler.
  • Each chapter contains almost the entire design of what you are building. The design and the hints provided are the keys to the simplicity and the power of this course.

The Elements of Computing Systems consists of 13 chapters contained in about 250 pages. Each chapter starts with a background section, describing relevant concepts. The next section is specification, which provides a clear statement of the system’s abstraction – namely, the various services that is expected to deliver. The chapter then proceeds to discuss how the abstraction can be implemented leading to a proposed implementation section. The next section, perspective, highlights the important issues left out from the chapter. Each chapter ends with a project section, which provides a detailed guide on building and testing the system described in the chapter.

Here is a summary of the chapters,

  1. Boolean Logic – The book starts with quick introduction to Boolean logic and logic gate circuits. Using the basic Nand gate, a hardware description language (HDL), and a hardware simulator, you will build other logic gates such as And, Or, Xor and Multiplexer. An HDL tutorial is provided in the appendix.
  2. Boolean ArithmeticHack Machine CodeChapter 2 introduces Boolean arithmetic and signed integer representation in computers. You will build logic circuits for adding binary numbers using the chips built in the previous chapter. Finally you will build an arithmetic and logic unit (ALU) capable of doing arithmetic and logical operations.
  3. Sequential Logic -  Introduces sequential logic and explains why a clock is necessary to maintain state in logic circuits. This chapter assumes flip-flop as the basic building block and then proceeds to show how memory registers can be built. You will build a program counter and memory units as large as 8K.
  4. Machine Language – Introduces a simple machine language capable of doing computation and memory access. The compute instruction is defined such that it can be implemented using the ALU built in the previous chapter. The machine language is simple and easy to learn and implement.
  5. Computer ArchitectureHack Assembly Instructions This chapter combines the hardware components and the machine language to build a full fledged computer. You will combine memory, ALU and control chips to build the Hack computer. A keyboard and display is also added using memory mapped I/O. In Hack architecture, instruction memory and data memory are kept separate.
  6. Assembler -  This chapter take us to the software land. You need to know a high level language to solve the programming problems from this chapter onwards. A simple mnemonic set is defined for the Hack machine language. You will then build an assembler for converting these mnemonics to actual machine language. 
  7. Virtual Machine – I: Stack Arithmetic – Many modern languages (Java, C# etc.) are compiled to an intermediate virtual machine code for portability. This chapter introduces a stack based virtual machine language/architecture. You will need to write a program to convert the VM instructions to the assembly language defined in the previous chapter. This is a complex activity and hence is split into two chapters.
  8. Virtual Machine – II: Program ControlHack VM Code This is a continuation of the previous chapter and you will build the program control part of the virtual machine. Once you have completed the VM to assembly converter, you can write programs with less effort compared to the assembly language.
  9. High-Level Language – Introduces a high level language called Jack. It is similar to Java but is more verbose so as to help the compiler writer. Write a number of programs in Jack language to get a feel for it.
  10. Compiler – I: Syntax Analysis – The next logical step is to write a compiler that can translate the high level Jack code to the virtual machine code. It is a complex project and hence is attempted in two chapters. This chapter introduces the syntax analysis and parsing techniques of compilers. You will write a parser for the Jack program to convert it into a sequence of tokens.
  11. Compiler – II: Code GenerationJack code for Tic Tac Toe Introduces the common compiler techniques for code generation. Using the parser from the previous chapter, you will write a full fledged Jack compiler. However you will need to use a number of library Jack classes for your program to work. In the next chapter, you will build these library classes.
  12. Operating System – Introduces the concept of an operating system. You will build a number of library classes in Jack language providing the basic OS services for the Hack platform. These include modules such as Keyboard, Screen, Output, Math, Array, String and Sys.
  13. Postscript: More Fun to Go – The final chapter provides a number of pointers to extend the Hack platform. Optimization and error handling are two obvious things to do. Another challenging thing would be to relax the rules of Jack language to increase the complexity of the Jack compiler.

All the required software (including source code) for the book is available on the nand2tetris home page.

The book is elegant, concise and very well structured. Clearly the course material has undergone extensive testing over the years. Each chapter provides hints so you get a high level idea of the solution. But it rarely tells you how to solve something. That is what makes this book so good. You have to really think and find solutions to tough programming problems. Also later chapters are tougher than initial ones.

I think there isn’t even a single redundant/unnecessary sentence in the book!

It took me around 20 days of dedicated work to complete the entire book including all the projects. It took me a while to solve the compiler code generator and the operating system chapter. I got stuck many times while working on the projects. I had an irresistible urge to look for solutions on the Web. But luckily I was able to overcome that urge and solve them on my own. This is something I suggest you do too. Don’t look up solutions on the web or forums. Try to solve problems on your own for the reward of intellectual satisfaction.

One limitation of the computer system we build as part of this course is that it can only work with 16-bit integers. This means that instruction memory size is limited to 32K. Since the code generators we build are not optimized, even simple Jack programs can lead to large machine code that won’t fit in instruction memory. This means that you won’t be able to compile your Tetris program all the way to machine code and then run it on the virtual hardware you built using HDL. Instead you will have to use the VM emulator to run your programs.

Finally this course reminds us the importance of abstractions in human progress. Most of the time we never need to look at what happens under the hood. Our abstractions protect us from all the underlying complexity. But never hesitate to look beyond the abstractions when needed.

Many colleges run computer science courses based on this book. The first half of the book is also available as a course in Coursera.

For a quick introduction to the book, please check out this short video by one of the authors (Shimon Schocken),


Computers have become an integral part of human existence. Almost everyone now carries a full fledged computer in their pocket! If you are looking for just one book that will help in you in understanding how computers really work, this is the book.

If you are a software developer or is planning to become one in future, you should read the book and complete all the programming projects. It will give you a deep insight into computer architecture and you will find it valuable throughout your career.

I enjoyed the book very much including all the projects in it. In fact this book gave me the best self-study experience in my life. The whole learning journey is one of intellectual thrill and intellectual satisfaction. Some may even find it a life changing experience. Highly recommended!

My Rating: 10/10

Every programmer should read The Elements of Computing Systems!

– Jayson Joseph Chacko

Further Reading/Additional Resources

October 2, 2016 | Posted in Programming | No Comments »

Book Review: Sapiens, A Brief History of Humankind by Yuval Noah Harari


When I read non-fiction books these days, I get a nagging feeling that the author could have communicated the idea in a much shorter book. Many books these days, especially in the self-help category, are bloated works converted from one or two blog posts. But very rarely you come across a masterpiece book and wish that it was bigger. Sapiens, A Brief History of Humankind by Yuval Noah Harari is one such book!

Yuval Noah Harari is an Israeli professor of history at Hebrew University of Jerusalem. His free YouTube course "A brief History of Humankind" covering 17 lessons and 62 videos is very popular. He wrote "Sapiens" originally in Hebrew and was later translated to other languages including English.

In less than 500 pages, Harari takes us through an exhilarating journey of human history. The topic of human history is so large, that it is a real challenge to decide what to include and what to ignore. Harari takes a high level view of human life over the centuries, but he also takes us through the perspective of common people when needed. Most of the things that traditional history textbooks usually cover are only very briefly touched upon.

Harari argues that it is our ability to gossip and believe in collective myth that has led to the unprecedented growth of human species. Everything that is the foundation of modern human civilization – money, religion, capitalism, consumerism and democracy is the result of our ability to believe in collective myth. Harari claims that it has enabled us to bypass evolution and even become gods on earth!

I am a huge fan of history and once I started reading it, I couldn’t put it down. The book triggers your imagination and curiosity. Harari tells many interesting stories. The lack of "political correctness" and "relaxed historical accuracy" may annoy or anger some readers! Here is an advice for easily offended readers – treat it as fiction!

Is there anything more dangerous than dissatisfied and irresponsible gods who don’t know what they want?

Summary: Sapiens, A Brief History of Humankind

Sapiens book is organized into 4 main parts covering last 70,000 years of human history,

  1. The Cognitive Revolution – Harari argues that it is our ability to gossip and believe in collective myth that led to the unprecedented growth of human species. He argues that it is this sudden ability that enabled us to be the only dominant human species on the planet. This part also takes a look at the day to day lives of early humans and explores the link between human growth and extinction of other animal species.
  2. The Agricultural Revolution – Is agricultural revolution history’s biggest fraud? Harari argues that for the farmers, this revolution manly offered suffering and death. This is an interesting conclusion since we think about agricultural evolution as a major achievement of human species. In more recent times, we have even started romanticizing farming and agriculture. This part also covers the evolution of language and bureaucracy.
  3. The Unification of Mankind – Harari argues that even though human culture has been in constant flux through the centuries, there has always been a definite direction to where we are going. Humans across the planet now form one large family. This part also explores the roles played by money, religion and imperial vision in unification of mankind.
  4. The Scientific Revolution – This section explores some of the reasons behind rapid industrial and scientific growth of European nations. Harari argues such a rapid advance is made possible by our acceptance of the fact that we know little about the world around us. It is our acceptance of ignorance that fuelled rapid scientific innovations. This section also explores the unification of the state, business and science.  Obviously there are dangers in the marriage of business and science.

Each of the above parts have 4 or 5 chapters dealing with topics related to that era. For example, one chapter looks at the origins of money while another chapter explores why agricultural revolution may be a disaster as far as individuals are concerned. Sometimes you get to hear an interesting story, sometimes you get to see a photograph of historical significance.

After going through the entire human history, finally Harari turns into the philosophical questions of human existence such as the meaning of human life and human happiness. He briefly touches upon the consumerism and its effects on human happiness. He points out that we are on the threshold of becoming the gods on earth!

Review: Sapiens, A Brief History of Humankind

Harari’s Sapiens is an excellent summary of human history. It mainly covers the last 70,000 years of human history. But it is not merely about history as Harari is more interested in the motivations of the people behind history. And it is also full of his own conclusions! He argues that the large-scale cooperation of human beings is what made us the masters of the planet.  He also briefly touches on philosophy and the chemical and biological interpretations of our behavior.

For any historian, it is important to at least partially suspend his personal beliefs while explaining historical findings. Harari does a very good job at that. He presents multiple viewpoints and theories of a historical event without actually taking sides. He admits that even today we are ignorant of many things including ancient history which left no evidence for us to study. However when it comes to conclusions, he has his own ideas which are very compelling!

Even though Harari doesn’t take any side in the debate of animal rights and vegetarianism, he paints a grim picture of the plight of domestic animals. There is no doubt that we are very brutal when it comes to industrial handling of animals used for meat and milk. The book contains plenty of horror stories. Historically my own local culture has been much more considerate towards the domestic animals, but money and industrialization is changing that. But here again, we need to be aware of the food requirements of 700 billion people!

One controversial part of the book is where Harari calls the agricultural revolution as history’s biggest fraud! He rightly points out that agricultural life has lead to lot of human suffering – tyranny of the elite classes, the quick spread of deadly diseases etc. Some are critical of this conclusion and argues that he underestimated the challenges faced by the so called happy "hunter-gatherers".

But we need to be aware that it is nearly impossible to make a judgment of history from our current privileged life. Many of the ideas and behaviors of my local community may be unacceptable to someone from a western country. In such a scenario, how can we judge people who lived thousands of years ago?

Towards the end of the book, Harari does a broad analysis of human happiness, looking not just at the philosophical question, but also the chemical and biological findings behind it. This section is sure to leave the reader confused if not completely depressed!

The small stories and intriguing photographs interspersed across the chapters makes the book a memorable read. It made me curious enough to investigate the background of the Lion-man, learn more about Gobekli Tepe and study the Buddhist teachings. And it made me think about what we are doing to our domestic animals bred for meat and milk.


Yuval Noah Harari’s Sapiens, A Brief History of Humankind is a brilliant piece of work. It is full of shocking and thought provoking stories. The vivid, crispy and witty language will dazzle you and its conclusions may even change your perspective on life. This is a masterpiece, get your copy today!

What do we want to want?

My Rating: 9/10

Further Reading/Additional Resources

August 18, 2016 | Posted in Opinion | No Comments »

Book Review: The First 20 Hours, How to Learn Anything Fast by Josh Kaufman

Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young.
– Henry Ford


I consider myself a learning junkie. I have a wide variety of interests such as chess, model railways, reading, DIY, programming, photography, travel, writing etc. Even the title logo of this blog is a collection of things that I am passionate about.  With a family of 2 children and a full time job, I find it is extremely difficult to spend time on my current hobbies let alone pick up new skills.

When I picked up the book, “The First 20 Hours, How to Learn Anything” by Josh Kaufman, I realized I am in the same boat as the author. Kaufman has a wide range of interests and claims that he spends a focused amount of time in learning something new and can become good at it in 20 hours. He calls this technique – “Rapid Skill Acquisition”. In this book, Kaufman covers the basics of this technique and explains how he applied it in learning a number of diverse skills. I was hooked!

How to learn anything fast!

Book Review: The First 20 Hours, How to Learn Anything Fast by Josh Kaufman

The First 20 hours, How to Learn Anything Fast is a book on “Rapid Skill Acquisition”. Kaufman claims that by following a disciplined process, it is possible to become fairly good in any skill in 20 hours of deliberate practice. The book starts off with a look at the 10,000 hour rule popularized by Malcolm Gladwell in the book Outliers: The Story of Success. Kaufman explains that 10,000 hour practice is needed for world class mastery, but not for becoming good at something. Most of the time we are not trying to become world champions or world class performers. We just want to be good at certain skills especially when we are pursuing hobbies such as chess or fishing.

Kaufman claims that it takes only 20 hours of disciplined and focused approach to learn any new skill from scratch (I am not sure from where he got this magical number!). He calls this approach “Rapid Skill Acquisition”. According to him there are four key elements of rapid skill acquisition,

  • Deconstructing a skill into the smallest possible sub skills
  • Learning enough about each sub skill to be able to practice intelligently and self-correct during practice
  • Removing physical, mental, and emotional barriers that get in the way of practice
  • Practicing the most important sub skills for at least twenty hours

Kaufman then explains the differences between skill acquisition, learning, training and education. This is followed by a detailed explanation of ten principles of rapid skill acquisition and ten principles of effective learning. I found these sections the most valuable part of the book. These principles also provide a good summary of the book,

Ten Principles of Rapid Skill Acquisition

  1. Choose a lovable project
  2. Focus your energy on one skill at a time
  3. Define your target performance level
  4. Deconstruct the skill into sub skills
  5. Obtain critical tools
  6. Eliminate barriers to practice
  7. Make dedicated time for practice
  8. Create fast feedback loops
  9. Practice by the clock in short bursts
  10. Emphasize quantity and speed

Ten Principles of Effective Learning

  1. Research the skill and related topics
  2. Jump in over your head
  3. Identify mental models and mental hooks
  4. Imagine the opposite of what you want
  5. Talk to practitioners to set expectations
  6. Eliminate distractions in your environment
  7. Use spaced repetition and reinforcement for memorization
  8. Create scaffolds and checklists
  9. Make and test predictions
  10. Honor your biology

I loved the following extract quoted by Kaufman from another book, Art & Fear: Observations on the Perils (and Rewards) of Artmaking by  David Bayles. This is a brilliant illustration of the power of practice (quality comes from quantity),

The ceramics teacher announced on opening day that he was dividing the class into two groups. All those on the left side of the studio, he said, would be graded solely on the quantity of work they produced, all those on the right solely on its quality. His procedure was simple: on the final day of class he would bring in his bathroom scales and weigh the work of the "quantity" group: fifty pound of pots rated an "A", forty pounds a "B", and so on. Those being graded on "quality", however, needed to produce only one pot — albeit a perfect one — to get an "A".

Well, came grading time and a curious fact emerged: the works of highest quality were all produced by the group being graded for quantity. It seems that while the "quantity" group was busily churning out piles of work – and learning from their mistakes — the "quality" group had sat theorizing about perfection, and in the end had little more to show for their efforts than grandiose theories and a pile of dead clay.

I found the first 40 pages of book informative and full of value. I have now adopted his methodology as a checklist whenever I try to learn something new. This book also got me interested in game of Go and Ukulele. 

However some may find that beyond first 40 pages of book, there is little to learn. In the remaining pages, Kaufman explains how he applied the rapid skill acquisition in his areas of interest. I liked these sections, but some readers may find it somewhat boring. I have also felt that in some chapters the learning process is presented as too easy and simple. For example, his learning process on programming seems so simple, yet in practice it is nothing but simple (except perhaps for geniuses). I think the author hides the fact that usually there is considerable time required for research activities. Hence you will end up spending much more than 20 hours to learn something.

I also ended up picking up a number of good books such as The Personal MBA and Art & Fear. Please see further reading section below for the full reading list.


The First 20 hours, How to Learn Anything Fast by Josh Kaufman is a mini manual for rapidly acquiring new skills. If you are passionate about learning new skills like me, you will find this book informative and engaging. The bulk of the book consists of how Kaufman applies the rapid skill acquisition techniques in acquiring skill in his areas. If that is not something you are interested in, I suggest you watch Kaufman’s TEDX presentation instead of buying the book.

Finally there is a larger question to answer before you pursue “rapid skill acquisition” to acquire a diverse set of skills. Do you want to be a jack of all trades and master of none?

For 37 years I’ve practiced fourteen hours a day, and now they call me a genius!
  – Pablo de Sarasate, Famous Spanish Violinist and Composer

My Rating: 7/10

Further Reading/Additional Resources

October 22, 2015 | Posted in Opinion | No Comments »