Code guy
Charles Petzold's new book -- this one for nonprogrammers -- is a
remarkable accomplishment.
A decade ago, back when MS-DOS's rule of the desktop was being challenged by
OS/2, Windows 3.0, GEM, and a handful of lesser operating systems, I bet on
Windows and started a little magazine called Windows Tech Journal. WinTech was
the first developers' magazine devoted to the Windows platform. My friends in
the publishing industry were skeptical -- Windows was too small a niche market,
they said, to support a whole magazine. My bet paid off -- I won't trouble you
with the details
-- and I spent a decade living, sleeping, eating, and dreaming Windows
programming.
Real programmers used C in those days. Their bible -- and mine -- was Charles
Petzold's remarkable Programming
Windows. This essential book did more than Microsoft's documentation,
megabytes of sample code, and the rest of the publishing industry's books and
magazine articles combined to explain how to write code for Windows. Petzold
simultaneously managed three difficult tasks: He explained how Windows worked,
how it was structured, and how application programs should interact with it. He
demonstrated through a series of crystal-clear examples how to write Windows
programs. And he somehow made the text lively and interesting even though the
book is one of the densest, most information-packed documents I've ever read.
I met Petzold long ago when we were recruited to participate in a
programming-conference panel discussion together. I've gotten to know him pretty
well over the years. In addition to being a meticulous programmer and a gifted
technical writer, Charles is one of our industry's nicest and most thoroughly
decent fellows. He has a shy grin, a quick wit, and an infectious laugh. He
always finds time to share a few minutes of friendly gossip when our paths cross
at programming conferences.
CHANCE ENCOUNTER
I don't really keep up with Charles's work anymore. I'm struggling to learn
Linux, not Windows. I rarely read PC Magazine, where his articles most
often appear. And Charles's devotion to ANSI C, which makes his programming
examples so clear, also makes them seem less relevant in these days of
newfangled high-level object-oriented component-based data-managing
Internet-enabled RAD environments.
Nonetheless, I keep my eye open for Petzold's byline. I was delighted to find
it in an airport bookstore a few weeks ago on the cover of Code: The Hidden
Language of Computer Hardware and Software. I flipped the book open to the
back flap and there was Charles's smiling face. I had to have it. I bought the
book and began reading as I waited to board my flight.
With Code, Charles Petzold and Microsoft Press are attempting to cross
over from Petzold's proven audience -- professional programmers -- to the broad
consumer market of nonprogrammers who are curious about how computers work. Code
is a very technical book about computers and software intended for a
nontechnical audience.
Charles Petzold is surely among the world's half-dozen most qualified authors
to write such a book. His understanding of computers and software is
comprehensive. His writing style, though true to the technical-writing
tradition, is clear and approachable. And Charles has an undisputed gift for
understanding and explaining complex topics. If anyone could make computers and
programming comprehensible to nonprogrammers, surely it is the author of Programming
Windows.
FROM HUMBLE BEGINNINGS
Code contains all the information you need to build a computer of your
own. Petzold begins with a battery, a loop of wire, and a bulb from a
flashlight. Then he adds a switch to demonstrate on and off. The
addition of a second switch leads to binary numbers: He shows how the circuit's
four states can be expressed in two binary digits: 00, 01, 10, 11.
Presented in parallel with the construction projects are explanations of
various codes. Petzold shows how Braille, Morse code, and ASCII work to encode
text, and explains how these codes might be related to the binary numbers
computers use.
The hardware projects get successively more hairy. By Chapter 12 we're
building an adding machine out of wires, switches, relays, and light bulbs. Step
by step, Petzold introduces more complex circuits and more advanced topics.
Gates and oscillators. Edge-triggered latches. Memory circuits. It's like an EE
degree in 400 pages.
Eventually, Petzold demonstrates how the machines he's diagrammed can be
programmed, and he explains how assembly language works. By this time, the
patient reader has all the low-level details of an eight-bit, 64K computer in
his head. So Petzold explains what operating systems do and sketches out how the
reader might write one.
It is a remarkable accomplishment. Petzold explains computers the way
Aristotle would have: methodically, exhaustively, along a meticulously planned
course from simple ideas to complex concepts. I didn't use wire and light bulbs
to build the hardware projects along the way as I read the book, but I'm sure I
could have. All the details were there.
WHAT'S NOT TO LIKE?
Let's start with an unassailable truth: This book is a remarkable
achievement. Petzold's trademark clarity is a match for the material. Squeezing
this much material into 400 pages is a miracle of logical thinking. Organizing
material this complex into a volume that proceeds naturally, with each chapter
building upon material presented previously, requires meticulous step-by-step
planning. I don't know who else could have written this book.
I am not the nontechnical reader Petzold and Microsoft Press envisioned for
this book. I came to the party with rusty but thorough knowledge of truth
tables, ASCII and other data-encoding schemes, assembly language, and the role
of the operating system. My background in software prepared me to appreciate
Petzold's thoroughness and clarity in presentation.
I do not have an EE degree, however, and I have always relied upon computer
hardware with only the fuzziest understanding of how the hardware worked. I
understand the programmatic effects of assembly-language opcodes, but I lack the
background to envision what physical changes result in the computer's circuitry.
So Petzold's lucid explanations of computer hardware were new and interesting to
me.
It is at this point that I come to my first reluctant criticism of this book.
Even though I have a technical background, and even though I was motivated to
learn the material, I found portions of Code mind-numbingly dense. There
must be a way to allow laymen to understand how computers work without
presenting circuit diagrams and exhaustive descriptions of level-triggered
D-type flip-flops, frequency dividers, and comparators. The schematics in the
first few chapters were clear; they added to the text. But by the time I reached
the middle of the book I found my eyes glazing over every time I encountered
another diagram. I was so grateful to find software-oriented chapters sprinkled
among the schematics!
If my first criticism regards Petzold's judgment in presenting too much
information on some topics, my second regards the places he provided too little.
Code runs out of steam near the end of the book, just about where Petzold
begins his discussion of operating systems. Petzold sketches operating systems,
peripherals, high-level languages, and graphic-oriented operating environments
with the lightest of touches. After devoting hundreds of pages to switches and
relays, Petzold devotes just 19 to graphical operating environments like Windows
and the Macintosh. Just as the story gets interesting -- as the book begins to
cover the kinds of computers we have around us today -- the in-depth coverage
ends.
Charles is a friend of mine, and it pains me to bring up even the slightest
criticism. But I think this latter flaw is significant. It would have been
better, I think, to end the book with an eight-bit computer and roll up all the
industry's achievements since CP/M into a brief concluding chapter. Alternately,
Petzold could have written another three or four hundred pages and extended his
in-depth discussion into modern computing environments. Given his rare gift for
explaining technology, Petzold is just the man to make modern
computer architectures, distributed computing, GUIs, objects, and the Internet
make sense.
It is not too much to hope, then, that Charles Petzold might one day write a
companion volume that picks up where Code leaves off. That would be a
book well worth reading!