What do jokes and bugs have in common?

I’m taking a stand-up comedy class at San Francisco Comedy College, and this week we’re learning about the structure of a joke. The essence of a joke is to create a setup, take one of the assumptions your audience made about the setup, and then reinterpret things slightly so that the assumption is violated – safely and comfortably. (Ah, nothing is so boring as writing about humor.) If you do this quickly and well, your audience will laugh. If you don’t, your audience might still laugh – at you.

This made me wonder why I sometimes laugh when I find a bug. A software bug exists because you have an assumption – say, all pathnames are PATH_MAX or fewer characters – and that assumption is being violated somewhere. When I find the place that assumption is being violated, sometimes I laugh. (Sometimes I sigh deeply and frown.) Perhaps when I smile, it’s because the violation is relatively harmless – my assumption was violated safely and comfortably? When you groan at a one-character bug, is it because it’s the moral equivalent of a pun? If you find out you have to rewrite ~500 lines of code, is that like making a joke about JFK’s assassination?

3 thoughts on “What do jokes and bugs have in common?

  1. Oh, that’s true enough… I often laugh on finding a hard to locate bug. Although in some cases, that’s because the alternative is crying… when you spend a week tracing through convoluted logic to find someone has confused equal with not-equal…

  2. I was amused when one of my bugs turned out to be something like
    #define MyFree(_x_) malloc(_x_)

Comments are closed.

%d bloggers like this: