Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API

From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@Demolishun Constant pointer or constant pointer value or constant pointer to constant value. Having to carry the length of things along with a pointer to them. Better not forget to terminate that string. null pointers.
-
Pointers is not just *. It's also the math of offsets for each datatype. Like @Demolishun said
oh, and also function pointers. -
You heard about pointers being hard, and you thought it referred to *learning about* pointers, when in fact the claim is probably that *using* pointers is hard, because although the concept is simple, they're massive footguns.
-
@netikras I don't know what you mean. T* is incremented by exactly sizeof(T). If you even acknowledge the exact values you're probably breaking the standard.
-
@netikras Function pointers are difficult if you try too hard to imagine pointers as numbers and not references. A function pointer can be thought of as the name of the function. In fact, that is exactly how many interpreted languages used to emulate the idea.
-
Hazarth93852yYeah no, pointers are easy. No idea what the others are even on about. No amount of pointer nesting, pointer arithmetics or pointer management is really *hard* as long as you keep being mindful of how your memory is managed, that is how is it allocated, how is it initialized, how many references to it there are, how are those references managed and when and how is the memory deallocated.
It's a lot to keep in mind while using pointers, but at no point I would describe it as "hard". In fact pointers aren't hard, good memory management is hard, but pointers are just the gateway drug -
@lorentz That's true - It's certainly why many modern languages don't use them, I imagine. Better ways to manage that idea behind the scenes with the extra abstraction.
-
Hazarth93852y@Demolishun huh, I'm surprised Valgrind didn't catch it. I find it's pretty good. Though to be honest, I didn't use Valgrind too much, I was always used to manage my own memory and I did cause my fair share of weird, borderland un-debuggable problems xD. Yeah pointers can be a headache. But I'd still argue that they get a reputation of being "hard" because some people do actually find them hard to understand. I never had the problem, but during Uni I had couple of people ask me about them and they had this really blank stare when I tried to explain why their code wasn't working and such...
So I always just accepted that pointers are not hard, just some people really do find them hard. It's almost as if some people just can't imagine the computer memory as a physical thing. At least that's the feeling I always got from them -
nitnip17712yThe concept is simple but just like templates in C++, a clever person can write really unreadable code with pointers.
-
@nitnip SFINAE magic is the bane of my existence. Sure it's fast, but most of the time it's write-only code.
-
I was an assembly language programmer before I learned C. “Oh, pointers are addresses” and it clicked.
Related Rants
Before I decided to learn C, I had heard tell of pointers being "hard to use". Of course I thought "maybe so, " after all, that was basically the only thing I heard about pointers, "they are hard!".
And so, when I learned C, and I got to the part about pointers, I was expecting at least some trouble (I can't know everything) and it was just... easy? Maybe the trickiest thing was how * has two different meanings based on the context (declare/dereference) but that was easy too.
Why the hell is all I hear from people about pointers is that they're difficult?
rant
pointers
c
fuck me