this post was submitted on 14 Jun 2023
36 points (100.0% liked)

Programmer Humor

421 readers
23 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 1 year ago
MODERATORS
 

A women sent her kid that was into programming to the grocery store and told it:

"Please buy 1 bottle of milk if they have eggs buy 2"

The kid returned with just 2 bottles of milk. When it's mom ask why it bought 2 bottles of milk, the kid said:

"Because they had eggs"

... Was the kid right?

top 9 comments
sorted by: hot top controversial new old
[–] AVeryCleverName@lemmy.one 19 points 1 year ago* (last edited 1 year ago) (1 children)

The child should have bought 3 bottles of milk.

[–] Deebster@lemmyrs.org 8 points 1 year ago

You're hired, when can you start?

[–] Deebster@lemmyrs.org 8 points 1 year ago (3 children)

I always think this joke is more of a linguistics/grammar joke than programming. The kid resolves the ambiguity in the ellipsis incorrectly, but why is this a programmer joke?

[–] Feyter@programming.dev 5 points 1 year ago (1 children)

Yes the joke is definitely on human language and not on programming but I think programmer can be relate here. At least I feel this joke is made in every computer science ground class ever.

[–] Navigate@programming.dev 4 points 1 year ago

I suppose it demonstrates the ambiguity of human language and need to formalize things for computers

[–] jalda@sopuli.xyz 4 points 1 year ago (1 children)

I heard this joke in Spanish, but the meaning is a bit different. Eggs is a colloquial/slang term for testicles (like balls in English), so "if you have eggs" means "if you dare".

[–] Deebster@lemmyrs.org 3 points 1 year ago

I love having a joke that works in two languages but for different reasons.

[–] Snaggen 1 points 1 year ago

The joke lies in interpreting human languages as if it was a computer algorithm. Remove any computer language context, and it is hard to even find a joke or logic in this. Any human would not do this interpretation since we can understand context, this would only be seen as a very strange attempt at a joke. However, computers don't understand context, so adding that component and the joke makes sense. So, even if it really is a grammar joke, it needs the programming context to work as a joke.

[–] kylxbn@iusearchlinux.fyi 2 points 1 year ago* (last edited 1 year ago)

For a serious reoly, I think the expression "If they have eggs, buy two" is redundant. If they didn't have eggs, the kid just can't and won't buy any eggs.

I think the proper command would be, "Please buy 1 bottle of milk and two eggs." That way, the kid won't be confused and it's still a proper valid command.

Unfortunately though, the sentence is ambiguous even to non-programmers. It is unknown whether the if condition applies to

  • buying two eggs (buy two eggs)
  • buying two bottles of milk (buy two bottles instead)
  • or buying a bottle of milk (buy another bottle)

Simply because they didn't specify which to buy.

For a non-serious reply,

cart.add(supermarket.takeProduct(ProductType.milk, 1));

if (supermarket.getProduct(type: ProductType.eggs).length > 0) {
    cart.add(supermarket.takeProduct(Product type.milk, 2));
}

cart.checkout();

The kid should have bought a total of 3 bottles.

load more comments
view more: next ›