
Code
by Charles Petzold · Published 1999
Complex computing systems become understandable when you trace them back to simple layers of representation, logic, hardware and abstraction.
What works
- Excellent first-principles explanation.
- Makes computer architecture accessible.
- Builds genuine understanding rather than tool-specific knowledge.
- Great foundation for developers.
What doesn't
- Long.
- Early chapters can feel slow.
- Requires patience and curiosity.
Summary
In Code: The Hidden Language of Computer Hardware and Software, Charles Petzold pursues a deceptively simple question: how does a computer actually work? But instead of a surface-level answer or an introduction to a specific programming language, he starts from the lowest possible layer — simple coding systems that have nothing directly to do with computers — and, step by step, layer by layer, builds up to a fully functioning computing machine.
The book's structure is gradual and cumulative: each chapter builds on the last, never asking the reader to simply take something on faith. Petzold starts with simple electrical circuits, arrives at logic gates, builds adder and memory circuits out of them, and finally shows how these same simple components, correctly assembled, become an actual processor.
The book's central message is that the apparent complexity of modern computers is an illusion built from stacked layers of abstraction; peel back those layers one by one, and at the bottom of everything you find nothing more than simple binary logic — on or off, zero or one. Understanding that path, in Petzold's account, builds a deeper and more durable understanding than purely tool-specific knowledge.
Key ideas
1. Morse code and Braille as the starting point
Petzold opens the book not with a computer but with two entirely non-computer coding systems: Morse code and Braille. He picks these two examples to show that the concept of a "code" — representing information through a limited set of combinable symbols — is far older and far more general than electronics. This unexpected opening pulls the reader away from thinking "a computer is some kind of magic box" from the very first pages.
2. Building logic gates out of telegraph relays
One of the book's famous sections shows how AND, OR, and NOT logic gates can be built using simple electromagnetic relays — the same components used in 19th-century telegraphs. Petzold constructs these circuits step by step, with precise diagrams, to show that Boolean logic, the theoretical foundation of computing, requires no advanced technology at all — it can be built with wire and magnets.
3. Why computers use binary
Petzold explains why the binary system, not decimal, is the foundation of electronic computation: an electrical circuit can easily hold two stable states (on/off, high voltage/low voltage), but building a circuit that reliably maintains ten distinct states is far harder from an engineering standpoint. This simple explanation clarifies one of the most fundamental, yet least often explained, questions in computer science.
4. Building a full adder from logic gates
After introducing logic gates, Petzold shows how combining these same simple gates builds a "half adder" and then a "full adder" — a circuit that can add two binary digits together and handle the carry digit too. This step is the book's turning point: for the first time, the reader sees how simple, meaningless circuits, when correctly combined, become an actual computational operation.
5. Layers of abstraction as the book's central thesis
The underlying claim of the entire book is that a modern computer is nothing more than a stack of layered abstractions — from transistor to logic gate, from logic gate to computational circuit, from circuit to machine code, and from machine code to high-level programming languages. Each layer hides the complexity of the layer beneath it so working at the layer above becomes simpler. Petzold argues that truly understanding a computer means being able to trace that path, layer by layer, down to the lowest physical level.
Who it's for
- Programmers who want a deep understanding of how a computer actually works — not just tool-specific knowledge of one language or framework.
- Anyone interested in the history of technology and electrical engineering — the book narrates the actual historical path to modern computers.
- Computer science students who want to build early intuition before formal computer-architecture coursework — the book is readable without prior technical background.
- Anyone looking for a fast, practical tutorial on a specific programming language — this book is about the underlying principles of computing, not coding instruction.
FAQ
Is this book good for starting to learn programming?
Not directly. This book is about the physical and logical workings of a computer, not instruction in a specific programming language. But for anyone who wants to build deep intuition about computers before learning to program, it's an excellent foundation.
Why does the book start with Morse code and Braille?
To show that "code" is a far older and more general concept than the computer — a system for representing information through a limited set of symbols. This opening pulls the computer out of "magic box" territory.
Why do computers use binary instead of decimal?
Because building a circuit with two stable electrical states (on/off) is far simpler and more reliable, from an engineering standpoint, than building a circuit with ten distinct states.
What exactly are the "layers of abstraction" the book refers to?
It means each level of computer technology (transistor, logic gate, circuit, machine code, high-level language) hides the complexity of the level beneath it so work at the level above becomes simpler. Fully understanding a computer means being able to trace that path down to the lowest level.
Do I need prior math or electronics knowledge?
No, the book starts from zero and explains every concept before using it. All you need is patience and curiosity, as the book's own listed cons also note.
Was this useful?
Counts appear once there are 5 votes.


