Friday, June 02, 2006

QOTD: The general lesson

The general lesson that I take away from this bug is humility: It is hard to write even the smallest piece of code correctly, and our whole world runs on big, complex pieces of code.
--Joshua Bloch
Nearly All Binary Searches and Mergesorts are Broken. Read all about it.

This chastening reminder is handy when I get frustrated to the point of apoplexy over things like lost work due to Blogger bugs. And other human endeavors. Bloch also says:
A bug can exist for half a century despite our best efforts to exterminate it. We must program carefully, defensively, and remain ever vigilant.
A jagged little pill, especially for the AI / singularity crowd.

On the other hand, it makes me feel better that I can find two silver linings:
  • A constrained-wordsize (say 8 bits per word) test case could have found this bug with an exhaustive-search test script a long time ago, and that I can see that makes me feel retrospectively smart.
  • If God-knows-how-many smart folks could miss this one for four decades, maybe I shouldn't be so hard on myself when I discover my own errors.