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?