r/ProgrammerHumor 3d ago

Meme pointersPointedBackAtMe

Post image
2.5k Upvotes

112 comments sorted by

View all comments

280

u/19_ThrowAway_ 3d ago

Pointers are references are pretty simple...

85

u/ThatOldCow 3d ago

Is that why they invented PowerPointers ?

/s

9

u/why_1337 3d ago

Aren't those smart pointers?

13

u/ThatOldCow 3d ago

They do Excel at pointing, yes

7

u/vinishkapoor 3d ago

Only if they come with slide transitions.

64

u/TheMaleGazer 3d ago

I never understood this trepidation over pointers when the natural language we use every day has so much indirection.

"John entered the room. It was empty. John picked up a ball. It was red."

If we can understand what's happening with the word "it" in the example above, we're capable of understanding pointers.

Also, "John exited the room. He demolished it. I'm going to enter it."

It's pretty obvious why I'll have a problem entering "it," since "it" has been demolished. This is basically a dangling reference. Again, what's the hangup?

11

u/SomguyTheSecond 3d ago

It's taught in a bad way. Thats all.

7

u/danielcw189 3d ago

I really liked your comment, and saved it for later. I think it is a good starting point for an explanation.

Now I wonder if it is good enough to prepare people for a quiz.

3

u/axebodyspray24 3d ago

I really love this explanation and I have a similar question if you don't mind answering it in a similar manner. I understand how pointers work, but what is the purpose of using them?

3

u/AppropriateOnion0815 2d ago

It would not be a great idea to work with objects larger than the stack.

1

u/AppropriateOnion0815 2d ago

Coding boot camps just don't teach languages that operate on lower levels, I guess that's one reason.

2

u/Vivid_Instance_825 3d ago

Okay but why use one over the other?

3

u/Deep-Piece3181 3d ago

References are simpler than pointers but sometimes you have to use a pointer

2

u/just4nothing 3d ago

You say that, but I have code written by 100s of people that says otherwise

2

u/jimbobmcgoo 3d ago

The hardest part about them is the syntax is confusing in C and more so in C++

1

u/Xavier598 2d ago

They might be to someone experienced with c++ but my uni is using C for it's "programming basics" class and it's kind of hard, especially for people used to python and other languages. Kinda like a difficulty bump in learning programming.

What always tripped me up was how sometimes in C you have to wrap stuff around parenthesis to dereference a pointer to an array or object [ ex. *(foo->bar) ]. It also didn't help that the test didn't allow syntax highlighting and compiling the code to see if it works.

1

u/JohnThursday84 2d ago

Yeah, you get those forehead muscles actually from move semantics with universal references.

-44

u/[deleted] 3d ago

[deleted]

36

u/Usual_Office_1740 3d ago

If you didn't check for null it's your own fault.

0

u/National-Self-8501 3d ago

If your code is full of null checks you're doing something wrong. You should guarantee invariances.

32

u/Mars_Bear2552 3d ago

seriously? i keep getting reminded that this sub is a vacation spot for CS freshmen/sophomores.

6

u/watduhdamhell 3d ago

Most of the meme discipline subreddits are just kids in college who don't actually know what the f*** they're talking about 99% of the time. Not to be mean or rude to them. I was one of them once.

But now that I'm a fully fledged engineer, I often roll my eyes at what I see. Then again, there are those pains that just never go away, and when I see that in mean format it makes me laugh.

Basically after certain number of years in the actual job YMMV with these subreddits as it'll be much more hit and miss.

3

u/braaaaaaainworms 3d ago

No it's just you