Debugging makes better scientists
What do scientists do
From Wikipedia:
Four essential elements of the scientific method are iterations, recursions, interleavings, or orderings of the following:
- Characterizations (observations, definitions, and measurements of the subject of inquiry)
- Hypotheses (theoretical, hypothetical explanations of observations and measurements of the subject)
- Predictions (reasoning including logical deduction from the hypothesis or theory)
- Experiments (tests of all of the above)
Scientists do this about reality.
What is debugging
From my personal experience and Wikipedia, while debugging your own program:
- Reproduce the problem (observe it)
- Distill the minimal input (hypothesize and eliminate extragenous factors)
- Track down the origin (predict results of the fix)
- Test to see if the fix works (experiment)
Program is like a complete universe. That universe becomes unknown if it is someone else’s code.
This is exactly what scientists are up to!
Programmers and scientists
I have met programmers, like lemmih, who can just guess how a program works by thinking how he would have designed it. And, gosh, is he usually right.
I wonder if that is how good scientists do it.
I have this inkling that this analogy goes deeper still. If you’ve ever taken part in a programming contest, then you know that you have to be very careful about what test cases you try out before you submit your program lest you should incur a penalty for an incorrect submission. I think that sort of testing also makes you a better rationalist in general by forcing you to think a bit more about the 2,4,6 problem.