Adam Barr — Find the Bug: A Book of Incorrect Programs — Addison-Wesley, 2010, 306p. ISBN 0-321-22391-8
This short book (306 p, but a quick read) asks us to debug 50 short programs written in 5 different languages: C, Python, Java, Perl, and x86 assembly. The book offers quite verisimilar code snippets, each of which containing exactly one bug; forfeiting the results. Barr proposes a taxonomy of bugs, from the logical bug to the off by one, and we must debug the programs with him.
The main problem I see with this book is that every language considered is not as finely exploited as it should be: Python programs are C programs; Java programs are C programs. I would’ve like to see the other languages used as they were meant to be, that is, to see exquisitely pythonèsque programs. On the other hand, if we lose the subtle scent of each language, it’s quite representative of what we see in real life: X language programs are merely transpositions of the same program in language Y. Another realistic touch is that programs do not seems to approach the problem considered for a given example by the best algorithm nor the shortest code—on many occasion I though “oh, I would’nt’ve wrote that!”. But overall, I think the examples where crafted with care, adding to the realism of the exercice of finding bugs.