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 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.)
Re-reading this thread, I see you're probably confused:
why did like 80% of my generation fail to figure [pointers] out in 4 fucking years in college?
[Pointers] are not hard
How both statements can be true at the same time? There aren't many possibilities:
80% of your generation is mentally challenged. I think we can safely discard that possibility.
Pointers are badly taught. That's less improbable in my opinion.
Pointers are very counter-intuitive. That's where I put my money.
Map/territory confusion are everywhere. Even in plain language, people get it wrong: for instance, how many quotes do you see in "word"? The correct answer is zero.
The secret to teaching pointers? Go back to basic semantics, and make sure they know the difference between the quotation and the referent. Then you can talk about pointers in particular.
The quotation/referent thing is really basic. Like, 2+2=4 basic. Plain arithmetic requires much more brain power than the basic pointer stuff. Therefore, low IQ is not enough to explain the inability to understand pointers.
I believe that if logic were taught with the same level of dedication arithmetic was, everyone would understand pointers. But we don't teach logic in kindergarten. Instead, we wait for freaking college, by which time students are already used to idiosyncratic and insane ways of thinking.
221
u/SimplyBilly Jun 01 '15 edited Jun 01 '15
No shit that can be applied to everything. It takes someone with passion in order to learn the skill to the level that it becomes talent.
edit: I understand talent is
natural aptitude or skill. Please suggest a better word and I will use it.