Saturday, April 6, 2013

What coding teaches you about life

Anyone who's ever been writing computer programs, no matter whether professionally or as a hobby, has surely had the following experience numerous times. You just wrote a script. It's not trivially simple but not very complicated either. While the task it's supposed to do or a problem it's supposed to solve is in a literal sense new, you actually have dealt with somewhat similar problems many times before so the task feels quite routine. You have a clear idea what you need to do. You write your code, careful not to make any stupid mistakes, and when it's obvious to you that it will do what it's supposed to do, you run it.

And it doesn't work.

Of course, since the task is conceptually straightforward to you, this must mean there's a very trivial error somewhere, an unmatched bracket or whatever. So you check the thing very carefully, line by line, for any sign of any stupid mistakes. And you find that there aren't any. Frustrated, you run it again. Of course this time, it doesn't work either.

You concede there must be a conceptual error somewhere, so you look up all the scripts you wrote in the past that dealt with similar things, to see where you've gone wrong this time around. And you just can't see it. It looks to you like this time you've done everything just the way you have all those times in the past; the only difference seems to be that in the past it was working and now it's not.

In situations like this, every programmer works from the assumption that the reason the code doesn't work is because they did something wrong, even though they have no idea exactly what they'd screwed up. They realize that you can be wrong even though you cannot possibly think of a reason why you'd be wrong. That the fact you have no specific idea about where you could be making a mistake isn't evidence that you aren't making one.

In short, this kind of experience teaches you that you don't know what you don't know.

This may all seem trivial, but I don't think it is. In life, real life, I see people who are unaware of this, all the time. People who think something to the effect of "I can't see any plausible way in which I could be wrong about this; therefore, I must be right". You can't do that when you code though. You can't just will your code to work because you see no reason why it shouldn't.

No comments:

Post a Comment