Category Archives: Guys from Bell Labs

Image

C++: the good parts

c++-the-good-parts

Programming Books, part 5: Programming Pearls

To my astonishment, I see that it’s been a whole year since the last  installment in the Programming Books series (1, Coders at Work; 2, The Elements of Programming Style; 3, Programming the Commodore 64; 4, The C Programming Language).  I got distracted.  But today I want to write about what I would judge the second best book on programming I’ve ever read: Jon Bentley’s Programming Pearls [amazon.comamazon.co.uk]

I tried to write about this book once before, but I was distracted by what it has to say about binary search, and that ended up being a whole series of its own (part 3, part 4a, part 4b, part 4c). Continue reading

Testing is not a substitute for thinking (binary search part 3)

The contributions to the original binary search thread continue to trickle in, and now stand at an astonishing tally of 679 comments, most of them containing code.  Thanks once more to all of you who’ve attempted this challenge, and to everyone who’s commented.

In one of the more interesting comments, Darius Bacon tested a sample of 20 of the Python submissions, and found that exactly 10% of them both passed the functional test and appeared to run in O(log n) time — which of course is exactly in line with Jon Bentley’s original statistic, that 10% of the professional programmers he’d examined were able to write correct binary search code (albeit under rather different conditions).  It subsequently became apparent, though, that Darius’s testing code was overly strict, and that a further two of the sampled routines did run correctly (though not necessarily in O(log n) time).  Still — it’s a surprisingly low hit-rate, especially when you bear in mind that, contrary to the rules, many of the programmers did use testing to help them develop the code. (You should read the second linked comment, as it has plenty of other interesting observations, too.)

[Update, an hour or two later: as Darius Bacon points out in a comment below, I misinterpreted his results.  Once the testing code had been fixed, his sample of 21 routines found 9 that passed all test, of which 6 were O(log n).]

Continue reading

Common bugs and why exercises matter (binary search part 2)

Many, many thanks to all of you who have contributed to the astonishing response to the previous article on the difficulty of getting binary search right.  I’ve never seen anything like this: in just over 24 hours since I posted the article, 541 comments have been posted, and they’re still rolling in.  (That number is a bit inflated by people re-posting the same code-samples multiple times after seeing WordPress mangle their source, but even taking that into account it still amazes me.)

You guys rule.  Seriously.

I have a lot to say in response to it all.  Read on …

Continue reading

Are you one of the 10% of programmers who can write a binary search?

There are some programming books that I’ve read from cover to cover repeatedly; there are others that I have dipped into many times, reading a chapter or so at a time.  Jon Bentley’s 1986 classic Programming Pearls is a rare case where both of these are true, as the scuffs at the bottom of my copy’s cover attest:

(I have the First Edition [amazon.comamazon.co.uk], so that’s what I scanned for the cover image above, but it would probably make more sense to get the newer and cheaper Second Edition [amazon.comamazon.co.uk] which apparently has three additional chapters.)

Continue reading

Programming Books, part 4: The C Programming Language

It’s 32 years old, and it remains the single greatest book ever written about a programming language.  Its crown is secure; even if you’d not already read the title of this article, you’d know what book I’m talking about.  It’s the only language-specific book in Top Five programming books of the Programming Reddit’s FAQ.  Co-written by Reinvigorated Programmer regular Brian W. Kernighan and Dennis M. Ritchie, it’s not just the definitive book about the language in question, it’s the book the rewrote the book on what it means to be definitive.  Step forward, please, The C Programming Language! [amazon.com, amazon.co.uk]

Continue reading

The hacker, the architect and the superhero: three completely different ways to be an excellent programmer

Like most programmers, I suppose, I’m arrogant enough to think I’m pretty good (although see The Dunning-Kruger effect).  But through the last thirty years’ programming, I’ve worked with plenty who I know are better than me.  Today I want to talk about three of them, and about how very different their skills are; and I’ll finish up by thinking about what the rest of us can learn from them, and what we can do to maximize our own abilities.

I agonized about whether to name them, but eventually concluded that I can say more about their work if I am specific; and what the heck, they might enjoy being held up as examples.  They certainly deserve it!  So step forward (in chronological order) Steve Sykes, Mike Selway and Adam Dickmeiss!

Continue reading

Programming Books, part 2: The Elements of Programming Style

I said in the first part of this series that one of the books I wanted to talk about was written in 1974.  My colleague Dennis Schafroth guessed that it might be Kerninghan and Ritchie’s classic, The C Programming Language, but the first edition of that book actually came out in 1978.  But I awarded half a point anyway, because the book I had in mind (A) was co-written by Brian W. “Water buffalo” Kernighan, and (B) had a second edition in 1978, the same year as K&R.  It is Kernighan and Plauger’s The Elements of Programming Style (amazon.com, amazon.co.uk)

(This isn’t a cover image from Amazon, it’s a scan of my personal copy, because I wanted you to see how well-thumbed it is.)

Continue reading

Some sushi I made the other day

I work for an open-source software house, Index Data, which is the world’s smallest multinational: although there are only twelve of us, we represent seven nationalities (Danish, American, Polish, German, Finnish, English and Canadian) and work out of eight different locations in five countries.

Last week, one of the American-based guys was in Copenhagen, so there were six of them all together, which is a bit of an event for us.  Purely to spite me, they all went out for sushi, and sent me a photo of the empties stacked up.

Living in the wilds of rural Gloucestershire as I do, there is no sushi to be had for love nor money for many miles in any direction, so I had to make my own.  And here it is:

Continue reading