My code sucks.

August 2nd, 2010 by konrad Leave a reply »

Cha­sing a link via Twit­ter, I recently read Your code sucks. Having gone over a lot of other people’s code mys­elf, and wri­t­ing code for long enough to have a good history of my own work to go over, it reso­na­ted with me.

I recently had the mis­plea­sure of debug­ging a piece of code that I wrote almost ten years ago. It was, in many ways, pain­ful to read. Alt­hough I still use the same lan­guage as back then, things have way evol­ved: The lan­guage, for one. Deve­lop­ment tools. (Well, not mine: I still use Emacs.) But most of all: My know­ledge and my men­tal hori­zon in pro­gramming. I’ve looked at various other things to enrich my skill set, brin­ging to my own coding hab­its tools that work well in other lan­gua­ges. I also got to under­stand the tools I use bet­ter (espe­cially data­base tools — those are so rich, and so few tools ever really use them). So, with that expe­ri­ence in mind: My code does suck. But I much pre­fer some­thing that I wrote ten years ago to be pain­ful to read, because it means that I have lear­ned a lot. Even though I feel great satis­fac­tion with the things I write today, I am sure that in ano­ther ten years time, I will look back at todays work and feel a slight sen­sa­tion of being asha­med of what I did.

And this hum­bles me in rea­ding other people’s code. It does not hurt to assume com­pe­tency in others; they may have dif­fe­rent rou­tes they take in sol­ving pro­blems. But if one gets to think like they do, under­stand why they wrote the code the way that they did, that cer­tainly may lead to your taking away some­thing for yourself.

Now, if only ever­yone adhe­red to K&R inden­ta­tion, I could read all the other people’s stuff so much more easily …

Advertisement

Leave a Reply