Code — Chapter 1: Best Friends
How flashlights, Morse code, encoding, and decoding demonstrate that meaning lives in agreed systems, not physical media.
Part of the series on Code: The Hidden Language of Computer Hardware and Software.
Main Idea
The chapter asks a deceptively simple question:
How can two people communicate when ordinary speech isn’t possible?
Petzold uses two friends communicating from separate houses at night. They can see each other’s windows but can’t easily talk to one another. A flashlight provides a solution.
However, simply turning a flashlight on doesn’t communicate much. They need a code: an agreed system that maps signals to meaning.
Morse Code
The solution introduced is Morse code. Instead of needing a separate signal for every letter, Morse code builds letters from only two basic signals:
- Short signal dot (
.) - Long signal dash (
-)
For example:
A .-
B -...
C -.-.
The physical implementation doesn’t matter very much. A dot and dash could be represented using:
- Flashlight: short flash / long flash
- Sound: short beep / long beep
- Writing:
./- - Electrical signal: short pulse / long pulse
The meaning is in the code, not in the flashlight.
Encoding and Decoding
Suppose you want to communicate HELLO. You first convert the letters into Morse patterns.
Encoding
Meaning
↓
Letters
↓
Morse symbols
↓
Physical signals
Decoding
The receiver performs the reverse operation:
Physical signals
↓
Morse symbols
↓
Letters
↓
Meaning
This same general pattern appears throughout computing:
Information → Representation → Physical Signal
The Deeper Lesson
Humans think about high-level constructs:
AHELLO42- A photograph
- A song
Physical machines don’t inherently understand any of these things. What matters is whether we can invent a representation for them.
A code is a system for representing information using something else.
Morse code represents letters using dots and dashes. Later, computers will represent information using other two-state systems. Morse code is introduced not because computers literally use Morse code, but to establish the idea of encoding information using a small set of distinguishable states.
Chapter 1 Compressed
Problem:
How do we communicate information?
Solution:
Represent information using agreed signals.
Example:
letters → Morse code → dots/dashes
Core principle:
Meaning can be encoded into physical signals.