3 ms·
Can you explain why? I heard about this, and avoided pointers for a long time because of a fear that comments like yours gave me. I then ended up realizing Ja
by aeonik 2y ago
Can you explain why?
I heard about this, and avoided pointers for a long time because of a fear that comments like yours gave me.
I then ended up realizing Java objects that I had been dealing with were just memory references, and that led me to learning about pointers in C.
Once I realized that I basically already knew what pointers were, I was pretty confused about why it created so much difficulty. Like it was an actual barrier for me to really understand how simple they are, so few moving parts.
It seems to me that everyone intuitively understands the difference between a home address, and the home itself.
Not to say that I'm an expert in pointer arithmetic or anything, I still prefer symbolic programming to dealing with pointers directly, for the same reason I prefer spoken English to Morse code.
- petre 2y agoBecause C syntax makes pointers harder to use and understand than they really are. Also constraints around pointers, casting etc. I still clearly remember figthing the C compiler and getting back "makes integer from pointer without a cast" complilation errors and segfaults. That's the main reason why I don't want to touch C or Rust again. D felt so much easier. I could finally write a program without endlessly fighting the compiler.
- aeonik 2y agoI've never programmed in D. I only here good things I definitely agree that stuff is pretty annoying. I guess I've gotten used to it to the casting behavior. Though these days I program mostly in dynamically typed languages.
- nunez 2y agoIf I recall correctly, the big gripe about them at the time was understanding all of the situations in which pointers can be used outside of simply accessing data, like setting one pointer to another one and doing pointer math with char-arrays (i.e. setting one variable's memory address to another). Like another poster said, much of this is unique to C and C++ without smart pointers.