Silly Mistakes

Every programmer has had this, or at least I like to think that every programmer has experienced this – you compile, press “go,” and epic failure. And the joy doesn’t stop there – then the debugging begins. Occasionally, one encounters a bug that gets the better of them, sometimes for hours, sometimes for days, and sometimes for months.

Hairs is pulled, teeth are gnashed, and eyeballs strain, scouring line after line. You try to convince yourself that your algorithm is correct, and that each line of code is justified. And yet, it still gets the better of you.

After perhaps eight hours, you swallow your pride, and ask a trusted friend to take a look. Often the very act of explaining things to another human being is helpful, but sometimes you both have to dig into the code. Maybe a third friend happens upon the two of you, and joins in.

Then, a light bulb goes off. If you’re lucky, it’s a massive structural change that’s required, but sometimes, it’s a single line, or a single word or character, and you suddenly find yourself embarrassed. But do not be. Every programmer I’ve ever met, no matter how qualified has run into these problems. Still, I find it easy to doubt my competence afterwards.

There are rare and beautiful moments when not only does code compile on the first try, but it runs as expected. Few and far between, cherish these when they come.

This is all inspired from a recent bug I tracked down. An embarrassing one. Sure, had I read the 350 or so pages of the OpenGL ES 2.0 specification, I may have caught it earlier, but this was one of those times when it was a single word that had to change. I tell myself that I won’t keep making these kinds of mistakes, and with each conquered bug I gain a tool, an experience point, and that’s what makes one’s craft.

I’ve looked at the time I spend debugging, and I’ve noticed that the time it takes to solve a bug can often be reduced by leaving the problem for a bit. Taking a walk, getting a cup of coffee, or sometimes watching an episode of Arrested Development. The desire to find and fix a bug is a siren’s song – nearly impossible to walk away from, but often a bad idea.

Tagged with:
 

3 Responses to “Silly Mistakes”

  1. Roni Choudhury says:

    What was the bug?

  2. dan.lecocq says:

    I was trying to display a screen-filling quad, and apparently WebGL (and OpenGL ES 2) doesn’t support GL_QUADS, but switching to GL_TRIANGLE_STRIP seems to have solved, though I’m only getting one of the triangles that way.

    What happens when you try to render a quad is a that a single pixel is drawn, and it appears to be on the interior of the primitive, but it’s hard to tell.

  3. John Brown says:

    Last paragraph absolutely true for me. Yet, it is SO HARD to let go and do smthg else for a while.

    We consider it a good day when we find a bug. The more we find, the better day it is. But, for every 3 bugs we find, we introduce a new one. So, it seems there are always more out there waiting to be discovered….

Leave a Reply