Secret Coders

coders Although I’m not sure that I’ve mentioned it here before, I’m a pretty big comic book nerd. So I was psyched when, late last year, Gene Luen Yang mailed me asking if I’d like a review copy of his upcoming graphic novel. I love Gene’s Avatar comics, which I had been reading with my kids, as well as his earlier American Born Chinese. What I hadn’t known is that Gene is a former computer engineer and high school computer science teacher.

Gene’s mail described Secret Coders — which comes out at the end of September 2015 — as sort of a Harry Potter but with programming instead of magic. It stars plucky Hopper Gracie who has to adjust to life at her strange new middle school while also, with her new buddy Eni, unraveling its many mysteries, some of which might involve her missing father. Along the way, the reader gets a clever introduction to binary numbers and Logo programming, the latter via a slightly mysterious robotic turtle character that obeys verbal commands. You can read an excerpt here. The book’s web site also has a 5-minute video introducing Logo, which makes it feel like this series might end up being as much of a MOOC as a graphic novel.

My 10 year old read Secret Coders almost as soon as it arrived. I should mention that he has read more of Gene’s books than I have (perhaps using the school library? I’m not totally sure) and has loved all of them. The kid is also a decent Scratch programmer and something of a novice at Python. He gave the book high ratings both for plot and for CS content. My eight year old hasn’t read the book yet; if he does, I’ll update this post with additional findings. Anyway, at $5.50 (Amazon price) this book is a great deal and I’d recommend it to folks who are hoping to get a young person interested in programming.

Update from Sep 17: The 8 year old is reading Secret Coders now and loving it. Too early to tell if he’ll pick up the programming content.

Atomic Accidents

Although I was six years old when the Three Mile Island accident happened, I clearly remember grownups talking about it and being worried: the house my family lived in was only about 60 miles away from the meltdown. In those days there was also plenty of free-floating nuclear angst due to the cold war; this would occasionally condense into something like The Day After or Edge of Darkness. The latter remains one of the best things ever to be shown on television, I re-watch it every couple of years (the 1985 one, not the 2010 one).

James Mahaffey’s Atomic Accidents covers not only Three Mile Island, Chernobyl, and Fukushima, but also pretty much everything else that has gone wrong when humans tried to exploit nuclear fission or fusion. It’s a fascinating book as well as being — perhaps oddly — quite funny, and I had trouble putting it down.

I was surprised to learn how many nuclear reactors have been destroyed on purpose, and I was also surprised to learn how many nuclear weapons were temporarily lost by the US military: something like 60 in total. That’s really scary. But perhaps the most chilling image painted in Atomic Accidents is the criticality accident where a small nuclear reactor is accidentally created, usually by someone working in a fuel processing facility. Imagine doing something innocuous like turning on a stirrer or pouring a liquid into a different container, seeing a bright blue flash, and realizing that you’re dead on your feet. This fascinating report contains a lot of details.

The accidents in large reactor facilities have some depressing common elements. First, the situation is inherently dangerous due to this large system that, under certain conditions, will get into a runaway positive feedback loop. Second, the thing can’t just be shut down to zero power: residual radioactive decay generates heat that has to be gotten rid of, necessitating extraordinarily complex cooling systems and backup power systems behind those. Third, visibility into the operating reactor is often poor: in one early accident, a reactor core had been on fire for several days before this was realized. Finally, humans, caught in between all of these factors, don’t seem to reliably do the right thing at the right instant.

A lot of pop science is written by people whose understanding of the issues seems to be shallow, but that is not the case here: Mahaffey is clearly a real expert on the subject matter. On the other hand, he is not unbiased. For example, on page XIX:

To keep the industry alive, thriving, and growing, it is imperative that the general population not feel threatened by it.

On page XXI:

The purpose of this book is not to convince you that nuclear power is unsafe beyond reason, or that it will lead to the destruction of civilization. On the contrary, I hope to demonstrate that nuclear power is even safer than transportation by steam and may be one of the key things that will allow life on Earth to keep progressing…

The best we can say is that it’s nice that he is up-front about this. Mahaffey’s slanted point of view caused me real stomach trouble only once: by page 33 he has twice asked the question: “Could we eventually evolve into a race that can withstand high levels of radiation?” What? For the human race to evolve in such a fashion, those who cannot withstand high levels of radiation must die — or be sterilized — before they can reproduce, repeatedly, over a period of hundreds or thousands of years. This is what might happen if the entire surface of the earth became dangerously radioactive. What was going on in Mahaffey’s mind that made this disturbing idea seem so appealing that he had to mention it more than once before the end of the first chapter?

Reading Iain Banks, Part 1

One of the enduring pleasures of my adult life has been the arrival of a new book by Iain Banks every year or two. Although that is over now, I thought it would be interesting to read his books in order of publication, and to write a bit about each. His first four books were published in 1984-87.

The Wasp Factory

I found this short novel to be immensely charming when I first read it 20-some years ago, and I still like it a lot. Frank — our hilarious, endearing, and psychopathic narrator — is on a bumpy journey towards self-discovery, discussing his odd pastimes and allowing us to piece together his troubling past. Concurrently, Frank’s brother has escaped from an institution and is making his way home one dog at a time.

Walking on Glass

Banks’ second novel has three storylines. A young man is on his way to meet his would-be girlfriend; in each chapter he walks down a different street, reflecting on their short history. Also in London, a paranoid and perhaps delusional man attempts to assemble evidence that he has been banished to Earth from some cosmic struggle. An elderly couple plays game after pointless game while imprisoned in a surreal castle. Connections between the storylines, subtle at first, become overt in the final chapters. The question here is whether the whole is more than the sum of the parts. I think probably it is, but not as much as Banks had hoped.

The Bridge

“It was all a dream” might not be the actual worst narrative device, but it’s probably on any “top 10 worst” list. The Bridge is all just a dream, and furthermore the narrator announces this fact right at the start: a gutsy beginning to be sure. There are three plot threads, each following an aspect of the narrator’s personality: an inhabitant of a massive, world-spanning bridge; a barbarian who speaks in phonetic Scottish; and, the actual narrator bringing us up to speed on his background and many emotional hangups. We might ask if this all works, if — again — the whole is greater than the sum of the parts, and this time it definitely is. The Bridge is one of Banks’ better-known books and deservedly so.

Consider Phlebas

I’ve heard the Culture novels described as “communist druggies in space” and this is somewhat apt: the Culture is an amalgamation of humanoid alien species that have upgraded themselves, and their environment, to such a degree that pain and scarcity are not part of most people’s experiences. Rather, under the supervision of super-intelligent and presumably benevolent Minds, citizens spend their lives entertaining themselves as they see fit. Since these folks obviously don’t make for very interesting reading, all of the Culture books deal, in one way or another, with the interface between the Culture and the rest of the galaxy.

Consider Phlebas takes place during a war between the Culture and the Idirans, a race of fanatical tripeds. The main character, Horza, is employed by the Idirans but is a changer — he can almost perfectly mimic another humanoid given time. Horza is tasked by the Idirans with capturing a damaged Culture Mind. This does not go well and nearly all of the novel’s characters are killed in the process.

Despite its grandiose set pieces, the tone of Consider Phlebas is dictated by Horza’s ever-narrowing choices: he is out of the frying pan and into the fire over and over; he can’t seem to win. Banks’ highly cinematic style works well for this grim space opera, though there are some awkward sentences and uneven pacing: the main action doesn’t get started until around page 300. Even so, the book manages to be about something, which is more than we can say for most SF.

A Few Good Books

I haven’t been getting a ton of reading done this summer, but here are a few books that you might find interesting or fun.

The Psychopath Test

I’m sort of emphatically not a fan of those lightweight nonfiction books we’ve been seeing a lot of in the past few years that would have made (and often did make) a great article in The Atlantic, but that ends up being repetitive and boring when expanded to book length. I was afraid this was one of those books, but it isn’t. What it is is Ronson stringing together a collection of personal and historical anecdotes about psychopaths; this works because Ronson is unusually gifted at getting people — often wingnuts, but also regular people — to open up and talk. For example, there’s Tony, the guy who pretended to be insane to escape jail time but now can’t get himself released from the hospital that holds Britain’s most criminally insane people. There’s Brian, a scientologist dedicated to debunking psychiatry. There’s Charlotte, who selects applicants for reality TV shows by making sure they’re crazy enough but not too crazy. I’m just scratching the surface, and Ronson is pretty entertaining himself, with a bit of a Woody Allen thing. This is a fun book about a really scary topic.

Are Your Lights On?

If you think about it, an awful lot of problems are caused by the fact that we’re often not very good at identifying the real problem in the first place. This book is a collection of mental tools we can use to do better problem identification. The general gist is to stop and think, and to make an effort to put aside our preconceptions, before just jumping in with a solution that may well make things worse. This kind of material should be useful for anyone but for consultants, engineers, and researchers it is vital. The book is short and funny and out of print but Amazon makes it easy to track down a copy. You should do it.

Tau Zero

Like all science fiction from 40 years ago, Tau Zero has become a bit of a period piece with respect to gender issues and politics, but otherwise it has aged reasonably well. The plot is pure hard SF: an interstellar ramjet is damaged in such a way that it cannot decelerate. To fix the engine, the crew is forced to take their ship into a region of extremely hard vacuum — the nearest such region being outside the galaxy. Due to relativistic time dilation, the long distances involved are not a subjective problem. One thing goes wrong after another and the solution always ends up being to accelerate, compressing time more and more. Early on, the crew realizes that nobody they know on Earth could still be alive; later, they notice that star formation has ceased. The book would be pretty horrible if Anderson turned it onto a physics lecture, but instead he focuses on the crew members and their reactions to an increasingly desperate situation. If you don’t feel like tracking this book down, no problem: just read this classic article by Freeman Dyson while watching the old Keanu Reeves movie Speed.

Dirty Snow

Previously I thought of Simenon only as the author of some fun detective stories that I had to read in French class. Dirty Snow, on the other hand, is one of the darkest books I’ve ever read. It is set in occupied France, but really it could be any wartime police state. The first part follows a young man’s willful descent into evil; in the second part he gains a bit of unwanted self-knowledge.

Funniest Computer Book?

The other day Eric Eide noticed The UNIX Hater’s Handbook on my desk and remarked that there aren’t enough funny computer books. This is undeniably true. So now I’m trying to find the funniest computer book and I’d appreciate some help. Here are a few guidelines:

So what’s left? Not that much, it seems. Here are a few ideas:

  • Mr. Bunny’s Guide to ActiveX — What even happened to ActiveX? Anyway, back in the day this was a pretty great parody of the kind of books you find in the programming section at Barnes and Noble.

  • The Computer Contradictionary — it’s The Devil’s Dictionary for computers (in fact the first edition was called The Devil’s DP Dictionary)

  • Dating Design Patterns — I haven’t read it but Eric says it’s funny

Thoughts? If you don’t have a suggestion, please just vote for something that I, or someone else, suggested.

Four Books on Debugging

It often seems like the ability to debug complex problems is not distributed very evenly among programmers. No doubt there’s some truth to this, but also people can become better over time. Although the main way to improve is through experience, it’s also useful to keep the bigger picture in mind by listening to what other people have to say about the subject. This post discusses four books about debugging that treat it as a generic process, as opposed to being about Visual Studio or something. I read them in order of increasing size.

Debugging, by David Agans

At 175 pages and less than $15, this is a book everyone ought to own. For example, Alex says:

Agans actually sort of says everything I believe about debugging, just tersely and without much nod in the direction of tools.

This is exactly right.

As the subtitle says, this book is structured around nine rules. I wouldn’t exactly say that following these rules makes debugging easy, but it’s definitely the case that ignoring them will make debugging a lot harder. Each rule is explained using real-world examples and is broken down into sub-rules. This is great material and reading the whole thing only takes a few hours. I particularly liked the chapter containing some longer debugging stories with specific notes about where each rule came into play (or should have). Another nice chapter covers debugging remotely—for example from the help desk. Us teachers end up doing quite a bit of this kind of debugging, often late at night before an assignment is due. It truly is a difficult skill that is distinct from hands-on debugging.

This material is not specifically about computer programming, but rather covers debugging as a generic process for identifying the root cause of a broad category of engineering problems including stalled car engines and leaking roofs. However, most of his examples come from embedded computer systems. Unlike the other three books, there’s no specific advice here for dealing with specific tools, programming languages, or even programming-specific problems such as concurrency errors.

Debug It! by Paul Butcher

Butcher’s book contains a large amount of great material not found in Agans, such as specific advice about version control systems, logging frameworks, mocks and stubs, and release engineering. On the other hand, I felt that Butcher did not present the actual process of debugging as cleanly or clearly, possibly due to the lack of a clear separation between the core intellectual activity and the incidental features of dealing with particular software systems.


Why Programs Fail, by Andreas Zeller

Agans and Butcher approach debugging from the point of view of the practitioner. Zeller, on the other hand, approaches the topic both as a practitioner and as a researcher. This book, like the previous two, contains a solid explanation of the core debugging concepts and skills. In addition, we get an extensive list of tools and techniques surrounding the actual practice of debugging. A fair bit of this builds upon the kind of knowledge that we’d expect someone with a CS degree to have, especially from a compilers course. Absorbing this book requires a lot more time than Agans or Butcher does.

debugging_by_thinkingDebugging by Thinking, by Robert Metzger

I have to admit, after reading three books about debugging I was about ready to quit, and at 567 pages Metzger is the longest of the lot. The subtitle “a multidisciplinary approach” refers to six styles of thinking around which the book is structured:

  • the way of the detective is about deducing where the culprit is by following a trail of clues
  • the way of the mathematician observes that useful parallels can be drawn between methods for debugging and methods for creating mathematical proofs
  • the way of the safety expert treats bugs as serious failures and attempts to backtrack the sequence of events that made the bug possible, in order to prevent the same problem from occurring again
  • the way of the psychologist analyzes the kinds of flawed thinking that leads people to implement bugs: Was the developer unaware of a key fact? Did she get interrupted while implementing a critical function? Etc.
  • the way of the computer scientist embraces software tools and also mathematical tools such as formal grammars
  • the way of the engineer is mainly concerned with the process of creating bug-free software: specification, testing, etc.

I was amused that this seemingly exhaustive list omits my favorite debugging analogy: the way of the scientist, where we formulate hypotheses and test them with experiments (Metzger does discuss hypothesis testing, but the material is split across the detective and mathematician). Some of these chapters—the ways of the mathematician, detective, and psychologist in particular—are very strong, while others are weaker. Interleaved with the “six ways” are a couple of lengthy case studies where buggy pieces of code are iteratively improved.


All of these books are good. Each contains useful information and each of them is worth owning. On the other hand, you don’t need all four. Here are the tradeoffs:

  • Agans’ book is The Prince or The Art of War for debugging: short and sweet and sometimes profound, but not usually containing the most specific advice for your particular situation. It is most directly targeted toward people who work at the hardware/software boundary.
  • Butcher’s book is not too long and contains considerably more information that is specific to software debugging than Agans.
  • Zeller’s book has a strong computer science focus and it is most helpful for understanding debugging methods and tools, instead of just building solid debugging skills.
  • Metzger’s book is the most detailed and specific about the various mental tools that one can use to attack software debugging problems.

I’m interested to hear feedback. Also, let me know if you have a favorite book that I left out (again, I’m most interested in language- and system-independent debugging).

The Space Child’s Mother Goose

I just noticed that this old favorite has been reprinted. A quick excerpt:

This is the Theory Jack built.

This is the Flaw
That lay in the Theory Jack built.

This is the Mummery
Hiding the Flaw
That lay in the Theory Jack built.

This is the Summary
Based on the Mummery
Hiding the Flaw
That lay in the Theory Jack built.

flaw_jack_builtThis is Constant K
That saved the Summary
Based on the Mummery
Hiding the Flaw
That lay in the Theory Jack built.

This is the Erudite Verbal Haze
Cloaking Constant K
That saved the Summary
Based on the Mummery
Hiding the Flaw
That lay in the Theory Jack built.

This is the Turn of a Plausible Phrase
That thickened the Erudite Verbal Haze
Cloaking Constant K
That saved the Summary
Based on the Mummery
Hiding the Flaw
That lay in the Theory Jack built.

This is Chaotic Confusion and Bluff
That hung on the Turn of a Plausible Phrase
That thickened the Erudite Verbal Haze
Cloaking Constant K
That saved the Summary
Based on the Mummery
Hiding the Flaw
That lay in the Theory Jack built.

This is the Cybernetics and Stuff
That covered Chaotic Confusion and Bluff
That hung on the Turn of a Plausible Phrase
Amd thickened the Erudite Verbal Haze
Cloaking Constant K
That saved the Summary
Based on the Mummery
Hiding the Flaw
That lay in the Theory Jack built.

This is the Button to Start the Machine
To make with the Cybernetics and Stuff
To cover Chaotic Confusion and Bluff
That hung on the Turn of a Plausible Phrase
And thickened the Erudite Verbal Haze
Cloaking Constant K
That saved the Summary
Based on the Mummery
Hiding the Flaw
That lay in the Theory Jack built.

This is the Space Child with Brow Serene
Who pushed the Button to Start the Machine
That made with the Cybernetics and Stuff
Without Confusion, exposing the Bluff
That hung on the Turn of a Plausible Phrase
And, shredding the Erudite Verbal Haze
Cloaking Constant K
Wrecked the Summary
Based on the Mummery
Hiding the Flaw
And Demolished the Theory Jack built.

Cyber War

I recently read Richard Clarke’s Cyber War. Although I didn’t learn anything new on the technical side, that isn’t the focus of the book. Clarke’s main agenda is to build awareness of the uniquely vulnerable position that the United States finds itself in as well as proposing national policies that might lead to a more favorable position for the USA as well as a more stable situation for everyone. Although I know next to nothing about Clarke, over the course of the book I learned to admire his blunt opinions and the broad perspective he has developed as a long-time Washington insider. This book is a couple of years old, and therefore misses out on recent developments such as Stuxnet. Even so, I’m not aware of a better high-level introduction to the policy issues. It’s worth reading as a way to understand some of the broader implications of computer (in)security.

Book Beginnings

If a book starts out just right, I’ll keep going back and rereading the first few sentences long after I’ve finished the book. Here are a few that did that to me.

Fagles’ translation of the Odyssey:

Sing to me of the man, Muse, the man of twists and turns driven time and again off course, once he had plundered the hallowed heights of Troy.

Gravity’s Rainbow:

A screaming comes across the sky. It has happened before, but there is nothing to compare it to now.

Blood Meridian:

See the child. He is pale and thin, he wears a thin and ragged linen shirt. He stokes the scullery fire. Outside lie dark turned fields with rags of snow and darker woods beyond that harbor yet a few last wolves.

I think the last one is my favorite.

A Different Approach to System Security

I enjoy it when science fiction has something useful to say about computer security. Towards the end of Iain M. Banks’ Matter, there’s a big space battle and we find this passage:

“Compromised,” Hippinse told him. “Taken over by the other side. Persuaded by a sort of thought-infection.”

“Does that happen a lot, sir?”

“It happens.” Hippinse signed. “Not to Culture ships, as a rule; they write their own individual OS as they grow up, so it’s like every human in a population being slightly different, almost their own individual species despite appearances; bugs can’t spread. The Morthanveld like a degree more central control and predictability in their smart machines. That has its advantages too, but it’s still a potential weakness. This Iln machine seems to have exploited it.”

Monoculture is an obvious and serious danger. For example, about the 2003 Slammer/Sapphire worm:

Propagation speed was Sapphire’s novel feature: in the first minute, the infected population doubled in size every 8.5 (±1) seconds. The worm achieved its full scanning rate (over 55 million scans per second) after approximately three minutes, after which the rate of growth slowed down somewhat because significant portions of the network did not have enough bandwidth to allow it to operate unhindered. Most vulnerable machines were infected within 10-minutes of the worm’s release.

Imagine the damage a similar worm could do today, or in 20 or 100 years, if properly weaponized.

I know there are automated approaches to diversity (ASLR, randomized instruction sets, etc.) but I found “they write their own individual OS as they grow up” to be a very charming idea, perhaps in part because it is so wildly impractical today.