Summary
Code is Charles Petzold's explanation of how computers work, built from first principles. Beginning with children sending messages to each other by flashlight and working through Morse code, Braille, Boolean algebra, transistors, logic gates, memory, processors, and operating systems, the book constructs a computer from the ground up conceptually. By the end, the reader understands not just that computers can add numbers but why they can, and how that simple capability extends to everything computers do.
The book's approach is genuinely unusual among computer science texts. Petzold does not assume the computer exists and explain its properties. He constructs it: starting from the physical phenomenon of electricity, moving through the relay (an electromagnetically operated switch) to demonstrate the logic gates that underlie all digital computation, then to Boolean algebra (which provides the mathematical framework for combining those gates), then to the circuits that can store binary information, then to the adders and memory and control circuits that together constitute a processor.
The historical context is woven throughout. Petzold covers Samuel Morse and Alfred Vail's development of telegraph code, Louis Braille's tactile alphabet, George Boole's algebra of logic (developed without knowledge that it would someday describe electronic circuits), and the Victorian engineers who built mechanical difference engines. The genealogy of ideas from these scattered historical sources to the modern computer is part of the book's appeal.
The final chapters cover floating-point arithmetic, operating systems, and higher-level programming languages — the software layers that transform a logic circuit into a general-purpose computer. Code was written in 1999 and predates the smartphone and the internet era, but the hardware concepts it explains are as relevant as ever. For anyone who wants to understand computing rather than just use it, Code remains the best starting point.
Key takeaways
- 1.
A computer is a logic machine built from switches that can be combined to perform Boolean operations — AND, OR, NOT — and those operations, combined, can implement any computation.
- 2.
Binary representation — encoding everything as sequences of 0s and 1s — is not an arbitrary choice but follows from the physical properties of two-state devices like transistors and switches.
- 3.
Boolean algebra, developed by George Boole in the 1850s for the algebra of logic, turned out to describe electronic circuits perfectly — a connection Charles Shannon demonstrated in his 1937 master's thesis.
- 4.
A processor is a circuit that can fetch instructions from memory, decode them, execute operations on data, and store results — a loop that repeats billions of times per second in modern CPUs.
- 5.
Memory stores binary information as the state of circuits that can be written and read; RAM (random access memory) allows any stored location to be addressed and retrieved in constant time.
- 6.
Machine code — binary sequences that a processor can directly execute — is the lowest level of programming. All higher-level languages (C, Python, Java) ultimately compile or interpret into machine code.
- 7.
Floating-point arithmetic allows computers to approximate real numbers at the cost of precision; the limitations of floating-point representation cause specific categories of numerical error.
- 8.
An operating system manages hardware resources — processor time, memory, storage — and provides a layer of abstraction that allows application programs to run without knowing the details of the specific hardware they run on.
Discussion questions
Use these on your own, with a book club, or as chat starters in Superbook.
- 1.
Did building up a computer from relays and logic gates change how you think about what your computer or phone is actually doing when you use it?
- 2.
The book shows that Boolean algebra — a pure mathematics invented in the 1850s — perfectly describes electronic circuits. What does that coincidence tell you about mathematics and the physical world?
- 3.
Petzold builds the entire computer from two-state switches. Does knowing that all computation reduces to ones and zeros change how you think about information?
- 4.
The historical narrative — Morse code, Braille, Victorian engineers — connects the modern computer to a long lineage of communication technologies. Which historical link surprised you most?
- 5.
Machine code is binary sequences a processor executes directly. Does understanding that level of abstraction make you more or less confident in software?
- 6.
Floating-point arithmetic approximates real numbers and introduces specific errors. Were you aware of that limitation before, and does it concern you in practical applications?
- 7.
An operating system abstracts the hardware so applications don't need to know about specific hardware. What other examples of beneficial abstraction can you think of in technology or daily life?
- 8.
Petzold builds up to a processor without introducing the internet or software at all. What does that scope choice tell you about where the complexity actually lives?
- 9.
The book was written in 1999 and predates smartphones. Which concepts it explains are most central to understanding mobile computing specifically?
- 10.
Code assumes no prior technical knowledge. Is that the right choice for a book about hardware, or does it mean the final chapters are too compressed?
- 11.
Who do you think would benefit most from reading this book, and how would understanding it change how they work?
Themes
Frequently asked questions
-
Do I need any programming or hardware background to read Code?
None. The book starts from scratch — from the physics of a flashlight — and builds up all the concepts it needs. It is specifically designed for readers who want to understand how computers work without any prior technical knowledge.
-
Is Code still accurate given how much computers have changed since 1999?
Yes. The fundamental concepts — logic gates, binary arithmetic, memory, processors, machine code, operating systems — have not changed. Modern processors are faster and more complex but built from the same principles Petzold explains.
-
What is the most important idea in the book?
That a computer is a logic machine: all computation reduces to operations on binary numbers, and those operations can be implemented with two-state physical devices. Everything a computer does is an extension of that one insight.
-
How technical is it?
It uses no mathematics beyond basic arithmetic and binary counting. The concepts are presented precisely but without calculus or advanced mathematics. Readers who are comfortable with following an extended logical argument will find it accessible.
-
Who should read Code?
Anyone who uses computers and wants to understand what they actually are. Particularly useful for people who work with software and want to understand what happens below the abstraction layers they work in, and for teachers who want to explain computing to non-technical students.
Similar books
The Information: A History, a Theory, a Flood
James Gleick
The Innovators: How a Group of Hackers, Geniuses, and Geeks Created the Digital Revolution
Walter Isaacson
Hackers: Heroes of the Computer Revolution
Steven Levy
Algorithms to Live By: The Computer Science of Human Decisions
Brian Christian and Tom Griffiths