09 July 2009

How to Tell If You're a Programmer

This is as close as I am going to get to talking about religion - a subject known as coding style. As it turns out, among programmers, there are certain things for which there are no definite answers, but an abundance of definite opinions. Your reaction to a few simple constructs might just indicate whether You are a programmer.

For example, how to implement an infinite loop. One mysteriously popular way to do this is

for(;;)

.. is just plain wrong! The 'for' loop is supposed to be for iteration through some well ordered set. The above atrocity iterates through nothing. In fact, you have to know that in the case of a degenerate conditional, the loop keeps on going. If you didn't know this, you could easily hypothesize that for(;;) might execute its loop zero times. And there it is - for(;;) is just degenerate. Things that are supposed to be there are left out. Left to imagination. Leaving no fewer than four punctuation marks in a bunch, seriously in danger of turning into perl of all things!

while(true)

.. is clearly the correct way to implement an infinite loop. What is ambiguous about while(true) ? The contract with while(condition) is that the loop executes while the condition is true. You could not even suspect that while(true) would ever do anything but loop, and loop, and loop ..

If you are wondering what all this means, congratulations! You are not a programmer!

If you know what I'm talking about, but you're are wondering what the point is, you probably are a programmer, but have reached some kind of Programmer's Nirvana. Lucky you!

If you totally agree, you are definitely a programmer, and can correctly construct an infinite loop.

If you totally disagree, that means you must be one of THEM.

And why is it that everybody hates

stay_here_forever: goto stay_here_forever

..?

< /flame_bait>

0 Comments:

Post a Comment

<< Home