3 ms·
Dude/ette; pointers WRECKED people's minds (myself included) when we learned about them in CS101 (modified for computer engineers) in 2006. I don't know why eit
by nunez 2y ago
Dude/ette; pointers WRECKED people's minds (myself included) when we learned about them in CS101 (modified for computer engineers) in 2006. I don't know why either; they make so much sense.
- ahartmetz 2y agoI think the one weird trick to understand pointers is to do a tiny amount of assembly programming. Assembly is very simple and pointers are everywhere. Writing useful programs in it is a chore, but you don't need to!
- cafeinux 2y agoI never understood the struggle people have with pointers, to me they are quite obvious, unless I'm missing some important thing about them. You have something you need to store; it's stored in memory; so you need to store its address if you intend on accessing it; so you store it in a pointer. From there, the rest comes logically.
- mainguy 2y agoI think the problem with C (well my problem) was the *& characters all over the place. I think because I spent too much time with pascal where (in my opinion) the pointer syntax is more symmetric.
- aeonik 2y agoCan 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.