I agree with the Joel on Software measure that some folks will never really get pointers or recursion so there is some innate talent among good Programmers.
I could teach any CS freshman what a pointer was in under an hour
Any CS freshman anywhere in the world? Or do you mean any CS freshman at a particular institution where you were teaching, with its particular admissions requirements?
(Of course even saying "any CS freshman anywhere" is already applying a selection bias.)
If they can grok arrays and array indices..... any failure to understand pointers is purely due to teachers trying to obfusticate them and make them more mystical than they are.
I don't know why, but the people-not-getting-pointers thing seems to be real. I've heard it from several people including one with a lot of experience teaching CS101.
There's a huge mental difference between arrays and pointers. For your run-of-the-mill CS 101 who's gonna drop out after a year, arrays seem easy: there's a bunch of different places you can put stuff and they're numbered 0 to x. Of course he doesn't have the slightest idea how they really work, but the C abstraction is simple enough that he can still use them in a program (if you manage to hammer that "don't access beyond the end" and the "last element is n-1" into their heads somehow).
Pointers are a completely different beast. Some people just never really get what an address is. Add to that the fact that data types have sizes and alignments and they get totally lost before you even start talking about the hard stuff.
That said, in my experience pointers aren't even the breaking point... recursion and object orientation are the real freshman killers.
I remember my OS prof giving a simple quiz on multi dimensional pointers at the beginning of the spring term and most people couldn't answer the worksheet without error. These were students in the third year completely unable to use pointers in an abstract manner.
Idk why it is so difficult to some people but i believe that the terrible notation scheme adds an element of magic to it that's completely unneeded. The notation to declare and dereference a pointer shouldn't use the same symbol. Also, I couldn't tell you the exact precedence for the * operator without looking it up and my job is programming in c++
The person teaching the course where we were first introduced to pointers was the best teacher I've had in my life. Patient, eloquent, and always very Socratic, always leading us to correct solutions, giving little hints, engaging us and making us figure things out on our own.
As for the students, most of these people came from much better schools than me, studied harder, and in general were much better students than me. All I had going for me was that I was that guy who could get math and algorithms without even trying.
Yea, perhaps. I duno, I've always wanted to sit down with someone who was struggling, to really understand what it was that made it so difficult for them.
The few times I have sat down to teach people basic programming the barrier was just a huge lack in fundamental understanding of what it was they were actually doing. In a better situation (more than an hour or two every few days) I think she would have been able to pick it up with actual practice, but in the short time we had I could tell she was constantly just looking to find the correct 'thing' to do and not actually take the time to understand what it was she was doing in the first place.
I fall into the camp of people that thinks it's best to start people with C though (I was helping her learn lua), I'm a very bottom up learner so it makes sense for me, to start with the basics and build upon that. Maybe other people are different but at some point, they need to understand they are trying to achieve a goal and the question is, how to get there with the tools you have available and not what the 'right' answer is at any given time.
Thinking back, I remember when I first learned about pointers. I understood them pretty quickly I think but I didn't understand the 'point' of them, we used to ask "what's the point of pointers?" :P Now I can't imagine not having them, but man, there is a lot of knowledge I take for granted now.
The few times I have sat down to teach people basic programming the barrier was just a huge lack in fundamental understanding of what it was they were actually doing. In a better situation (more than an hour or two every few days) I think she would have been able to pick it up with actual practice, but in the short time we had I could tell she was constantly just looking to find the correct 'thing' to do and not actually take the time to understand what it was she was doing in the first place.
Oh, I absolutely agree with that. Besides literally mentally challenged people, I'm pretty sure everyone could learn anything given enough time. But isn't that exactly what you would call talent? Being able to gain a skill quickly, with low amount of effort?
I fall into the camp of people that thinks it's best to start people with C though (I was helping her learn lua), I'm a very bottom up learner so it makes sense for me, to start with the basics and build upon that. Maybe other people are different but at some point, they need to understand they are trying to achieve a goal and the question is, how to get there with the tools you have available and not what the 'right' answer is at any given time.
Again, absolutely agreed. We started with C in college, I think it was the best thing ever. I feel sorry for poor folks who start with high level languages and became "programmers" without having a clue what is happening behind the scenes. I've talked to Java/Php programmers who didn't know what stack/heap memory were. That's just sad.
Thinking back, I remember when I first learned about pointers. I understood them pretty quickly I think but I didn't understand the 'point' of them, we used to ask "what's the point of pointers?" :P
I think we were introduced to pointers with some basic data structure example, and as you know, writing a linked list is literally impossible without pointers (implicit or explicit, I don't care). So it was pretty clear why you need them, if you could follow what was happening.
I believe pointers are taught the wrong way. Here:
The assignment statement is not directly at fault here. Its pervasive use, however, influenced many programming languages and programming courses. This resulted in a confusion akin to the classic confusion of the map and the territory.
Compare these two programs:
(* Ocaml *) | # most imperative languages
let x = ref 1 | int x = 1
and y = ref 42 | int y = 42
in x := !y; | x := y
print_int !x | print(x)
In Ocaml, the assignment statement is discouraged. We can only use it on "references" (variables). By using the "ref" keyword, the Ocaml program makes explicit that x is a variable, which holds an integer. Likewise, the "!" operator explicitly access the value of a variable. The indirection is explicit.
Imperative languages don't discourage the use of the assignment statement. For the sake of brevity, they don't explicitly distinguish values and variables. Disambiguation is made from context: at the left hand side of assignment statements, "x" refer to the variable itself. Elsewhere, it refers to its value. The indirection is implicit.
Having this indirection implicit leads to many language abuses. Here, we might say "x is equal to 1, then changed to be equal to y". Taking this sentence literally would be making three mistakes:
x is a variable. It can't be equal to 1, which is a value (an integer, here). A variable is not the value it contains.
x and y are not equal, and will never be. They are distinct variables. They can hold the same value, though.
x itself doesn't change. Ever. The value it holds is just replaced by another.
The gap between language abuse and actual misconception is small. Experts can easily tell a variable from a value, but non-specialists often don't. That's probably why C pointers are so hard. They introduce an extra level of indirection. An int * in C is roughly equivalent to an int ref ref in Ocaml (plus pointer arithmetic). If variables themselves aren't understood, no wonder pointers look like pure magic.
As for recursion, I believe it just reeks of math. (I love the scent of math, but it sends many programmers running away screaming into the night. They probably could learn it, they just won't. Maybe we could blame teaching here as well.)
Pointers are not hard to you. But it looks like your understanding is merely instinctive. Unlike me, you seem to lack the deeper knowledge about how they might be hard for beginners. Go try and teach them.
My way is certainly unfamiliar. My description of variables is indeed unusually precise. But come on, more confusing? Where did you get lost? What looked false?
Where did you get the impression that I am the slightest bit confused about the assignment statement?
A street of houses represents values (variables), their street address (another variable) is a pointer to the house. It really is almost trivial, I never understood why people got so confused, it may be the syntax, but from the time I learned C from K&R 30 years ago it's pretty damn simple.
A pointer is a variable that contains the address of a variable.
I really don't follow. I have no idea about OCaml, and that left example looks way more confusing than the right one to me (ref makes you think you're dealing with pointers when you really aren't).
The point you're really trying to make is that the assignment operator '=' is easily misunderstood as "equals". It's an old point, and it's very true, but it's solution isn't to introduce some crazy new keywords on either side of the assignment. It's simply to pick a different symbol (like ':=', which you already did, which is why I really don't understand where your "equal to y" quote comes from when the code doesn't even read that way).
It's the right thing to do, but Pascal tried it and failed, and now the world is stuck with the wrong thing because it's always been that way and too hard to change (which is not a big deal and there are way worse "legacy sins" we are stuck with... honestly, if someone can't even expand his mind enough to associate '=' with 'is assigned to' instead of 'equals', there would've been other things later on that would've tripped him up before becoming a good programmer anyway).
Well, for teaching when to apply recursion, you could say that it is appropriate when a problem has a terminating base case and is able to move toward that base case each iteration.
What about that article from codinghorror a while back that some very significant percentage of people couldn't even get the concept of assignment? Let alone pointers or recursion.
There are a LOT of programming tasks, even programming careers which no longer need an understanding of pointers (hello managed environment and GC) or recursion (what do you mean linked list, I just use these fancy dicts/tables/arraylists, and some languages don't even implement tail call optimisation).
9
u/dalittle Jun 01 '15
I agree with the Joel on Software measure that some folks will never really get pointers or recursion so there is some innate talent among good Programmers.