The purpose of art is to delight us; certain men and women (no smarter than you or I) whose art can delight us have been given dispensation from going out and fetching water and carrying wood. It's no more elaborate than that. — David Mamet

Lots of books about the practice of programming are written for raw beginners, for people who don’t know what they’re doing, who need their hand held gently, and often for people who don’t want to be studying this topic. They spend a lot of time coaxing and cajoling and telling little jokes to keep the kids from getting scared.

A second strand of recent books about programming, starting from Fowler’s Refactoring and Beck’s Test-Driven Development By Example, aren’t written for beginners but, like the children’s stories, they move in tiny steps and chiefly address topics that seem fairly simple. I read Refactoring from start to finish and, the whole time, I was convinced that the next chapter was going to get interesting. I finished it, shrugged, and a couple of weeks later I began to realize, “Hey! That was sort of interesting!” This predilection for great care in taking tiny steps is partly the result of the modernist preference for tiny-methods style, partly a matter of temperament, and (I suspect) partly the result of careers spent consulting for software managers who don’t really know what they’re doing but who hold the checkbook.

xUnit Test Patterns fits solidly in this tradition. It’s exhaustive and fairly exhausting, laying down the law for unit testing and showing in detail exactly how each step can be taken without fear of fouling everything up. Much of what’s covered here is probably already part of the working vocabulary of any programmer with enough experience to read the book, but because Meszaros gives names to stuff you already do, he makes it easier to talk about those things and to justify them.

I took away three things.

Everyone knows that unit tests really need to be fast. Meszaros puts a number on it: 100ms per test is not fast. Meszaros spends pages showing why 100ms is not fast. It’s overkill, presumably aimed at giving you lots of information to vanquish your pointy-haired boss, but it’s good to know.

Second, shared fixtures are a pain. I knew that. I’d developed a test style that returned fixtures to their proper state after I used them. Meszaros argues that it’s better just to make fresh fixtures if you can manage that, and this seems to me a big win.

Finally, there’s a fine paper on Humble Object by Mike Feathers that I’d missed. It’s a good reference to have.

So yes, it’s made a concrete difference in Tinderbox Six. I’m not sure this needed to be a book, and there’s another book about refactoring practice that’s trying to bust out of this one. But it’s certainly worth having and browsing this book, and you could do worse than to spend a few evenings working through it in detail.

March 27, 2013 (permalink)


Debug It!
Paul Butcher

I saw this on Nate Matias’s bookshelf when I was stowing conference supplies in his office at MIT. Nobody tells me about good books in my field, so I take note of what people seem to be reading. Finally, I found some time.

It’s a good book. Debugging is a skill; half the questions I see at StackOverflow could have been resolved fairly quickly if the writers had better debugging skills. Butcher walks through the basics with patience and tact, showing inexperienced programmers how to find bugs and pointing out some kinds of problems that are tricky to find.

This is a book for the inexperienced, and it stops when things are getting interesting. Yes, asynchronous and multithreaded code is hard to debug. We knew that! And yes, doctor, we know that if it hurts when we do that, it might be a good idea to avoid doing that. Sometimes we can’t avoid it. Sometimes, the bugs appear when we’re already hip deep in the Big Muddy. Sometimes, the Big Fool says, “Management decided to architect it this way. Fix the damn bug.”

There are two kinds of tricky bugs. The first is the masquerade party: something is going wrong, it’s clear what the problem is, but that can’t happen. I had one of these publishing this post. A newly-rewritten method, ConstantTextSize, was crashing because when it called CreateAttributedString because, whatever it was getting from CreateAttributedString wasn’t an AttributedString. That’s nice, but it turns out that CreateAttributedString only returns AttributedStrings. I spent a lot of time proving that it could only create an attributed string. And then proving that the object it was complaining about was, in fact, an attributed string. So, why the crash? Because the text encoding was fouled up and we were looking beyond the end of the string, and an attributed string made up of garbage is not an attributed string as far as the system is concerned, no sir! So, we marched out of that river and now, when you use a whole slew of mathematical symbols in a post, Tinderbox won’t holler at you the way it hollered at me.

Masquerade parties take time but they’re kind of fun. The other tricky bug is the Epic Storm, and it’s no fun at all. Debug It! book avoids bogging down in war stories, but in a way that also falsifies the experience of debugging. I really hated Ellen Ullman’s The Bug, but it did get one thing right: an epic bug is a terrible thing. Everyone is screaming and shouting and generally emoting all over the place. Survival depends on finding the thing. Somehow, whatever is wrong keeps going wrong. You think it’s fixed, you pop the corks, you ship. And then it happens again. And again.

Over the years, we’ve had some awful epic bugs. They had names. Storyspace Ate My Links was the worst, but the Tinderbox unit tests have plenty of methods named for the great customers who filed the reports. I think we’ve only had two category five epic bugs in the last few years, though; test-driven development has helped, and perhaps experience and whisky have helped keep things calmer than in the old days. (One is fixed, the other is still open but we think it lies deep in the Carbon libraries where no program went before, and where no program is ever going to go again.)

One of the great contributions of Martin Fowler’s Refactoring was that it gave a name to one of the best approaches to addressing an intractable bug. If you can’t find the problem, and localization strategies can’t quite pin it down, you can just refactor the hell out of the neighborhood. This may or may not fix the bug, but at least it improves the code. Before refactoring, bug hunts left tracks all over the program in the form of hooks and temporaries and diagnostic writes. Nowadays, bug hunts leave mown lawns and cleaner design.

March 26, 2013 (permalink)


A wryly over-the-top mystery set in the midst of a power struggle in a 1990s Women’s College in Cambridge. Our hero, the Bursar, brings an old friend into the school to lend a hand with the political infighting; when the Mistress is murdered, things get badly out of hand. After a reverse in a faculty meeting, suffered at the hands of the women’s studies/queer studies faction, the Bursar exclaims “Time and again we were warned of the Dykes!” A good time is had by all.

The incredibly ghastly cover doesn’t matter in the $2.99 Kindle edition.

February 1, 2013 (permalink)


The Aviator
Gareth Renowden

Truffle farmer and magazine expert Gareth Renowden ventures into SF with this lively romp through a ruined earth in the wake of global warming. Global cataclysm doesn’t phase Lemmy, his intrepid Airshipman, nor his gallant, artificially intelligent airship, from making their corporate rounds. The opening has buckets of exposition — not unexpectedly, perhaps, given Renowden’s expertise in eco-journalism — but there’s plenty of fun.

The book is structured as a series of encounters with isolated pockets of survivors. This familiar approach can be compelling, but it helps to give the protagonist more narrative direction than laid back Lemmy can consistently muster. Still, this feels like early late-period Heinlein, and that’s not a bad thing.

January 26, 2013 (permalink)


Beautiful Creatures
Kami Garcia and Margaret Stohl

I tend to like just about everything I read these days. My stack of urgent reading is so large that it almost always contains something I’m eager to read, and if that disappoints at first, there’s always something else to start. Beautiful Creatures titrates right down to the edge. The movie trailer seemed good, and The Hunger Games and Divergence were so much fun that I hoped for another YA find.

This is the story of a young fellow in Gatlin, South Carolina, who falls for the New Girl In Town. Unlike everyone else in Gatlin, she’s not from here. She’s lived in distant places. She thinks deep thoughts. The other girls hate her.

Oh, and her whole family are supernaturals. And on her 16th birthday, she has to make an irrevocable choice between light and dark.

There are good bits here. I enjoyed the moment when, telling off her sexy and evil older cousin, our heroine shouts, “Get away from my boyfriend, witch!” The co-authors insert themselves neatly into the book as a pair of librarians. The writing is clean for the most part, though an editor should have noticed that, when a character is knocked unconscious at the end of a chapter and looks at “my cell” at the start of next, readers may assume that he’s observing his place of confinement, not his iPhone screen.

But, in the end, Garcia and Stohl never engage the fear they’re writing about. That fear is the mystery of puberty as experienced by pre-adolescents: suddenly, kids you’ve known, kids who were simply “big kids” on the periphery of your life but still part of society, are transformed into something else. They don’t have time for you. Some of them get ugly. Some of them get mean. And the clock is ticking: one day you will wake up and be one of them.

Beyond the big flaw, there are lots of technical issues. Ethan, our hero, tells us a lot about small town Southern life. He has known no other life, but his is an outsider’s description. Scout Finch can get away with this because her dad’s a loner, but Ethan’s family are insiders back to the War of Rebellion. Where does he get his perspective?

It’s not clear to me that this ought to be a Southern Story; formally, it’s a New England story (the past rises up to kill you) and not a Southern Gothic (there is a terrible secret). And there are lots of little things: when our best friend ditches school vacation at Bible Camp and heads to New York for a week with a girlfriend’s older, supernaturally hot cousin, nobody appears to ask him the question that’s got to come first amongst the sophomore boys: how far did you get? This whole book is about sex, but nobody is ever permitted to think about it.

January 18, 2013 (permalink)