When I gave up on pointers
hI started programming with that orange turtle ( I think it was supposed to be green, but we had bad CRT screens ) by drawing stuff on the screen. I think that I was in fifth grade or so. I later graduated to VB (IIRC, that was VB3 or VB4), but my first formal programming education was done in Pascal. And I was pretty good (for a high school kid who merely dabbled), but I just couldn’t figure out pointers. I mean, they made absolutely no sense whatsoever.
Take the example of an “infinite” size stack, that was the example that we were given during class, and I just couldn’t follow it. Take the stack example, like so:
You might notice that this code is limited, if you are storing more than 3 items, the value will be silently ignored, which is probably not what you want. High school me would agree that this is bad, and therefor increase the STACK_SIZE variable to a ridiculously high size, such as 100). That would surely be big enough for everything, right?
I remember really struggling with the concept of dynamic memory management, not so much as because of the API, but because I couldn’t make any sort of sense about what I was supposed to do there.
After high school, I went and high end course in C++. That took about a year, and I highly recommend the course (even though I don’t think they run it), it taught me a lot about basic stuff such as how things actually work. We started with low level C in DOS, and build on top of that all the way to MFC and ATL. And at some point, the instructor introduced dynamic memory management. And it was so blindingly obvious that I never actually realized that I’m learning the same concept that gave me so much grief in the past.
I had that experience several times since then. I try to learn something, and I just bounce, hard. At a while later, I do the same thing, or fight a slightly different, and get it. Bug I’m no sure how I go from “what the hell” to “oh, this is obvious”.
Comments
Thanks for sharing this. I've had similar experiences. I chalk it up to context and perspective changes brought on over time. Sometimes when faced with a very challenging problem, I'll walk away from it for a day or two, work on something else, and then come back to it. Often just doing that helps me see the problem in a new light and the answer seems obvious. I like to think of this as divine inspiration but I think writers often refer to it as the Muse.
'Fight a bit different'. Nice analogy.
Case of pointers: there are no vars of type pointer in this code example. TopPointer is a misleading name. Hence the title?
Maybe has something to do with proper teaching - i also struggled to get the concept of pointers while learning C from the Kernighan/Ritchie book (the concept was OK and i understood it to some extent, but couldnt get why it's useful and how to use pointers in a sensible way). Things started changing on a proper system programming course at the university, with introduction of OS-level concepts and more advanced data structures, suddenly i was seeing what is the OS and how much thought was put into the infrastructure.
It is amazing how much the brain continues to work on a problem, subconsciously and occasionally consciously when it bubble to the top of the thought stack, when you go on to something else.
If I find a problem seeming to be too difficult to grok, I'll move on to something else know that later, or tomorrow, or even longer time periods later my mind has (usually) formulated a solution that I just need to implement. Usually the Ah Ha! moment is just telling you that your async brain task has just completed :)
Comment preview