Monthly Archives: June 2014

Programming Problems

The programmer’s wife says: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”

The programmer comes home with 12 loaves of bread.


I’ve got to be honest here: I have very limited programming experience and probably cannot dissect this joke as thoroughly as a more seasoned programmer would. Nevertheless, I think it’s a cute joke. It’s definitely worth a mention and a cursory explanation.

I do know enough about programming to know that the order and phrasing of instructions is of utmost importance. The programmer’s wife opened with an instruction to get a loaf of bread, then followed with a conditional test: if they have eggs. A conditional test can be either true or false. If the test evaluates true, then the set of instructions immediately following the test is to be carried out.

Unfortunately, the wife left her instructions ambiguous; she told her husband to get a dozen, but didn’t specify what he was to get a dozen of. A normal human would have inferred that he should get a dozen eggs, not a dozen loaves of bread, but a computer is incapable of inferring meaning from ambiguous instructions. Interpreting the instructions in the same way a computer might, the husband assumed that the term dozen referred back to the loaf of bread. Now they can have sandwiches for months, but no omelets.

Advertisements