2007-05-15

On Programming

Numerous reliable sources agree: I have a lot to learn about the art of programming. I'm not hurt. I'm not offended. I acknowledge that for as many scripts as I've whipped up and as many little bits and bobs of code that do my mundane tasks for me, automation is not programming, per se.

Now, I fully admit that I read a lot of code and I am continually amazed when I see some snippet, some line of brilliance, that just jumps out at me the fifteenth or sixteenth time I've read it. When this happens, I get struck, full on Colonel Kurtz "diamond bullet through the brain"-style by how amazingly the programmer has solved a problem that I have just recognized in a single line.

After a while, the amazement becomes routine. I'm always surprised at where I find such a gem, but I look for it. I expect to find it. I don't usually expect to find it in my own code, however. Surprisingly, this happened to me just this morning, when I found that a simple (!foo && bar) conditional works for every case for which I needed it, not just the one I originally had in mind when I wrote it. The reason why this surprises me is because I tend to be a very analytical thinker: if you have data that needs to fit three criteria, you test for the first thing, then the second, then the third. If you're really elite, you reject data after each test to make sure you don't waste more time than is necessary.

Woo-wee! You're some sort of 31337 haxor now, buddy. But I seldom, if ever, find so graceful and so elegant a solution that I can basically just run one test and have a definitive answer that, for example, can determine if a string of numbers fits a specific pattern for which I am looking.

Smart code. It's all new to me.

No comments: