4 ms·
> saw the next chapter was literal witchcraft and gibberish (pointers), got overwhelmed I remember being very confused for a time by C pointers as an undergrad
by andyjohnson0 3y ago
> saw the next chapter was literal witchcraft and gibberish (pointers), got overwhelmed
I remember being very confused for a time by C pointers as an undergrad in the late 80s - a situation that none of my teachers really helped with. Eventually I realised that they were just memory addresses, and a whole lot of confusion collapsed into a simple concept. I still remember what that felt like in my head.
Turned out that many of my peers had a similar experience, and not all of them got through it.
So I'm wondering yet again: why do people find C pointers so difficult to grok? Is it conceptual (indirection), notational (& and *, arrays as pointers, etc), or something else?
(Pre-uni I'd devoted a lot of effort to getting VIC and SID chips to do stuff with peek and poke commands, and writing some assembly language, which I reckon did me no harm when I first encountered C - even though I probably didn't immediately recognise the connections. I do wonder what the contemporary equivalent is.)
- alfanick 3y ago> So I'm wondering yet again: why do people find C pointers so difficult to grok? Is it conceptual (indirection), notational (& and *, arrays as pointers, etc), or something else? I think people need some background of computer architecture and operating systems before working with pointers, then instead of "what the heck are these addresses?" you get "oh that's how I can use all of these addresses, finally, yay, pointers" moment. If you just learn C/Cpp and related without the background, it's some magical and cumbersome feature.
- wadd1e 3y ago>So I'm wondering yet again: why do people find C pointers so difficult to grok? For me, understanding pointers to data types was not the hard bit(int* or some_struct*), but wrapping my head around *array being a pointer to the first part of a contiguous segment of memory took a lot of time. Once that idea(and what ++array_pointer really did) settled in my head, pointers felt fairly normal to deal with.
- chmod600 3y agoThe concept of memory address needs to make sense, first. The idea that memory is a big array of typeless bytes, and that all data exists in there somewhere. That an address is just an array index into memory, and you can use it to point to the first byte of an integer or struct or string or whatever. I mean, it kind of makes sense but it's not obvious.
- ziml77 3y agoWhen I first learned to program at John's Hopkins CTY class back in middle school (~2002), we learned on C++. We didn't wait long to get to pointers because we learned not just how to get the computer to do what we wanted but also about what was going on underneath. When you are in a mindset of thinking about how things are being placed into memory, pointers become a much more natural concept.
- twodave 3y agoI suspect a lot is determined by presentation. Explaining arrays using physical dimensions breaks down after the 3rd dimension (and even the “cube of elements” examples tend to be a bit contrived). Expressing them as categories/levels of a nested loop would have been a lot more understandable for even my 16-year-old brain. Pointers weren’t completely inaccessible for me, but the syntax was so alien that nothing felt intuitive anymore after a certain point in the book. Most of the C operators I had learned to that point looked familiar to a lot of the math ones I already knew. Modulo made sense immediately. The Boolean ones were sensible enough. The bit-wise ones were okay once you at least know to convert to base 2 and back. Pointers just didn’t intuit the same way.
- ezconnect 3y agoIt was probably the teaching method. I had an easy time understanding Physics and Trigonometry class but during Algebra it's hard to digest and understand. Then I got older and found that there's a lot of teaching methods and if the teacher is good at adapting the lesson to the students lots of students will understand. Sadly most teachers are not flexible, it's just too hard for them to accommodate all students teaching needs.