On Being Wrong

From Slate’s interview of Peter Norvig, director of research at Google on being wrong:

If you’re a politician, admitting you’re wrong is a weakness, but if you’re an engineer, you essentially want to be wrong half the time. If you do experiments and you’re always right, then you aren’t getting enough information out of those experiments. You want your experiment to be like the flip of a coin: You have no idea if it is going to come up heads or tails. You want to not know what the results are going to be.

And on errors in computer programs:

No matter how good you think you are, the industry standard is that if you write 100 lines of program, there’s probably going to be one error in it.

I found out a few days ago that a heavily-used computer system I helped develop 11 years ago had a bug all that time, but which only revealed itself last year. I suspect the bug lay in code I wrote. For 10 years, the particular feature worked as expected, and was used every day. And yet it was broken all along.

Okay, that’s my example, but I am a mere mortal at programming. What about the immortals? Well there is Joshua Bloch, Java guru, who literally wrote the book on effective Java, and who wrote significant parts of the Java libraries. A couple of years ago he discovered that Java’s binary search method was broken. This method, which he wrote, had a bug which lay undiscovered for 9 years. Bloch’s conclusion:

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.

Once you accept that your code is almost certainly wrong, you become a better programmer. Instead of feeling insulted when someone finds a bug in your code, you feel grateful that you get the chance to fix the bug and make your code stronger. You try to make it easy for bugs to reveal themselves with as much useful information as possible. You code more carefully, you use static analysis, you believe in code reviews, you appreciate comprehensive testing, and you encourage people to report problems.