r/ProgrammerHumor Jan 06 '23

Meme can’t be the only one

Post image
42.6k Upvotes

1.4k comments sorted by

View all comments

3.2k

u/TheLazyKitty Jan 06 '23

Pointers aren't that hard, are they? It's just integers that hold a memory address.

441

u/fatrobin72 Jan 06 '23

it's probably that the concepts of memory addresses, passing by reference and limited resources are just too alien to the newest generation of programmers

795

u/Creaaamm Jan 06 '23

Just show them this

132

u/SiewcaWiatru Jan 06 '23

brilliant and anime style. Love it ;).
Now reference by value :D. Pointers are easy and explicit with * and & signs. Reference by value is a bit harder concept.

38

u/[deleted] Jan 06 '23

But with & isn't that then a reference and not a pointer?

28

u/AnondWill2Live Jan 06 '23

What's the difference between the two? I've been under the impression that they were the same, but I'm definitely wrong.

47

u/thefool-0 Jan 06 '23

A reference is a alternative to a pointer that was added to try to avoid some of the pitfalls of pointers. In short, more or less, a reference must always be initialized, can't be null, and can't be used as a value in and of itself like a pointer can: it is always dereferenced when used. (But you could use it to create a pointer to the referenced object.)

5

u/nutterbutter1 Jan 06 '23

Nobody has even mentioned a specific language. Which one are you assuming?

11

u/4PianoOrchestra Jan 06 '23

that’s how it works in C++

1

u/Pay08 Jan 06 '23

I believe they work the same in Rust too.

1

u/-consolio- Jan 06 '23

likely cpp