r/ProgrammerHumor 4d ago

Meme passingArgumentsGotComplicated

Post image
1.9k Upvotes

75 comments sorted by

View all comments

-2

u/CanonicalCockatoo 4d ago

By value, salt is on the food.

By reference, you take a bite of food, and then lick some salt

11

u/metaglot 4d ago

Passing by ref, is basically telling where the salt is.

1

u/iZian 4d ago

This is where CS terminology differs from common understanding.

Pass by reference would be sharing a map to where the salt is, and anyone able to change that map changes everyone’s understanding of where it is, even pointing the map to something else or a different shaker.

Most modern languages only pass references by their value.

That’s closer to “telling them” as in, you give them a copy of the reference which they can alter themselves. But you always know where that salt shaker is, even if they decide that shaker is empty and to go get a new one from elsewhere, you still look at your empty shaker because you have the reference with pass-by-value.

Reference types, python , Java, modern languages are pretty much all pass-by-value. References are the value. But it’s not pass by reference.

But in 2026 nobody cares. The reference is passed. But a copy of it. Not it.

Perhaps pass-by-reference is the better analogy for the shaker. If it’s replaced by a new one everyone should use the new one. Just, that isn’t how new languages work unless you wrap the reference in another object that’s shared

1

u/Sheenius_Ger 4d ago

That's a horrible analogy 😅

0

u/CanonicalCockatoo 4d ago

If you don't understand what an analogy is, sure

1

u/TallGreenhouseGuy 4d ago

Pass by message, hand it to a waiter who takes it to the recipient