this post was submitted on 13 Jan 2026
122 points (89.6% liked)

Programmer Humor

28863 readers
1325 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 

A wife tells her programmer husband: β€œGo to the store and buy a gallon of milk. If they have eggs, get six.”

He comes back with six gallons of milk. When she asks why, he replies: β€œThey had eggs".

you are viewing a single comment's thread
view the rest of the comments
[–] Feyd@programming.dev 13 points 2 weeks ago (4 children)

I've never liked this joke. I guess it's supposed to be that the husband does the literal action as described, but instead it's just that they interpreted ambiguity opposite than expected? It just really doesn't work very well :/

[–] rockerface@lemmy.cafe 66 points 2 weeks ago (2 children)

The joke is bad because the husband is supposed to bring seven gallons of milk. Since the egg condition is checked after he already got one.

[–] NaibofTabr@infosec.pub 18 points 2 weeks ago* (last edited 2 weeks ago) (1 children)

No no, the imperative "get six" overrides the previous "buy a gallon of milk" if the "they have eggs" condition is met.

"get six" implies x === 6 not x = x + 6, that would be "get six more"

The real problem is that "buy" was only specified in the first case. Because the conditional was met, he should get six gallons of milk but not buy them.

[–] ulterno@programming.dev 3 points 2 weeks ago (1 children)

Now just how did he procure the rest of the 5, is a mystery.

[–] mech@feddit.org 1 points 2 weeks ago* (last edited 2 weeks ago)

He cloned the supermarket.

Omg, you’re so right. I didn’t read it that way until you pointed that out.

[–] jbrains@sh.itjust.works 7 points 2 weeks ago (1 children)

Given the stereotypical difficulty of "product folks" and programmers agreeing on and building shared understanding of what to build, this joke seems clear and straightforward. It works because of course, the customer and the programmer failed to agree on something simple.

That is why we have spec docs, duh. /s

[–] dnick@sh.itjust.works 5 points 2 weeks ago (2 children)

Maybe it's just worse when written. The period at the end of the sentence makes it hard to see how it could be misunderstood.

To your point though, not sure if I'm aware of any programming language that would continue a statement with a following if block. Far more likely that it would fail due to lack of an element to apply the 6 to rather than having a pointer to the previous object, or he would try getting what ever the literal version of a 6 would be, or maybe some slang version.

[–] ignirtoq@feddit.online 7 points 2 weeks ago (1 children)

Python, though the logic would be backwards:

milk_gallons = 6 if eggs > 0 else 1
[–] dnick@sh.itjust.works 0 points 1 week ago (1 children)

Right, it would be started basically exactly the opposite. Certainly not a statement followed by an if block.

[–] ignirtoq@feddit.online 1 points 1 week ago

The code block I wrote is a statement followed by an if. What I meant be "backwards" was the order of conditions, not that the statement came after the if. It's exactly what you asked for.

[–] eager_eagle@lemmy.world 3 points 2 weeks ago (1 children)

any language that allows ternary conditionals

[–] dnick@sh.itjust.works 1 points 1 week ago

Those would all start with the if, followed by two conditions, not a statement and then an if. There would be a condition to evaluate, followed by then/else?

[–] sping 4 points 2 weeks ago

I'm pretty sure I've heard effectively the same core joke but better composed. Can't remember it though because at best it's middling funny.