Saturday 24 May 2008

Use the Cluebat, Luke!

Many are stubborn in pursuit of the path they have chosen, few in pursuit of the goal.
F. Nietzsche

Sometimes us programmers are faced with what I would call the most ridiculous and humiliating aspect of our work:

You come across a problem. You start thinking about it. You find it ever more complicated, but you go on and on. Actually, this is only one of the obstactles in your way to achieving your original goal, it's probably not even got something to do with what you were trying to accomplish in the first place...

Finally you come up with a solution. It took you 2000 lines of code, it reduced your app's performance by 40%, true, it still may have some bugs you don't know of - along with a couple of bugs you know but have no idea how to solve and hence try to sell as features; but, hey! the problem was complicated, after all! And you solved it. Yay!

The glistening, glaring enlightenment strikes you once you're presented with a comment such as

"Why didn't you just use random one-liner-solution X?"
on your work.

Of course, your immidiate response goes "Huh?". Your brain feels like it's shrinking. No words available, they're all gone, along with your self-esteem, your thinking your're intelligent and all your coding skills. You've just spent a week's worth of coding time in vain. Everything you did was ugly and totally uncalled for. You take the blame.

This happened to me yesterday, and the apathy and fear of code is still here, hampering my productivity and just about everything. If it wasn't for the great music pumping out of my speakers, I would even not feel competent enough to blog about it... Here's what I did.

I'm currently working on porting a second-language-acqusition-aiding-system (Think taaaanks! We need a nice buzz-word for this, pronto!) from mod_python to Java & Servlets (in Tomcat), utilizing the Apache/IBM UIMA-architecture. The program fetches remote web sites and performs (not-so-)random input enhancement on them. The problem was displaying remote websites properly on my own server, just like Google Translation does. Long story short, I went to considerable lengths to replace all relative paths in a given page with absolute ones to get the source adresses for extra content right. It worked. Sort of.

Then I went to my advisor, and, whoops... Ever heard of the HTML <base> tag? Me neither. It's not even ONE line, replacing all of my crafty and barely readable regular expressions. My conscience faded. Good thing I didn't drop dead right on spot, though I surely wanted to.

Now I have to gather focus on performing the serious tasks at hand. Fortunately that's something I should know better - really, I think this sort of mistakes happens because you hit a spot in your app where you have to perform a task you don't know shit about. You don't know the libs people use there, you don't even know how to approach the problem. I asked people on #tomcat and #java on freenode.net, but they couldn't help me either. They were all programmers, I should've asked some web designer. But I didn't... I went all finite state on it, bombarding the poor thing with hideous regexps, wasting my time on a problem that didn't really have to exist in the first place.

Oh well, 'tis one of the moments, where I just tend to pessimism, reminding myself about this great quote I came along in Nietzsche's "Menschliches, allzu Menschliches". Strangley, pessimism, like doom metal makes me go optimistic.

Nothing lives which would be worthy
of your striving, and the earth deserves not a sigh.
Pain and boredom is our being and the world is excrement,
—nothing else.
Calm yourself.
G. Leopardi

There it goes. People screw up stuff all over the place. This time it had to be you. You're not even special in failing. Go on, dipshit.

No comments: