A wife asks her husband, a programmer, “Could you please go shopping for me and buy one carton of milk, and if they have eggs, get 6?” A short time later the husband comes back with 6 cartons of milk and his wife asks, “Why did you buy 6 cartons of milk?” He replies, “They had eggs.”

I find this to be the most unfunny programming joke in the dozens of programming jokes I’ve heard since I started programming. It’s even worse than the “Why is Halloween the same as Christmas?” joke – at least that one’s a cute coincidence for number systems.

At first glance, it looks like a straightforward joke: a direct translation of the statement make the husband buy six cartons of milk:

milk_to_be_bought = 1 if they_have_eggs milk_to_be_bought = 6 end buy_cartons_of_milk(milk_to_be_bought)

But that’s not even a direct translation! A direct translation would be:

buy_one_carton_of_milk if they_have_eggs buy_six_cartons_of_milk end

This results in the husband buying 7 cartons of milk!

But no, the conversion from command to program is still incorrect. Here’s a much more direct translation:

buy_one_carton_of_milk if they_have_eggs get_six end

get_six what?

That’s the thing: no self respecting programmer would do what the husband did in the joke. A joke computer scientist would not do anything until the linguistic ambiguity is resolved, while a joke software engineer would also refuse to do anything until the unclear requirements are clarified, documented, and signed off.

Now if the joke went like “A wife asks her husband, who just started Codecademy last night…“, it would probably work.