A classic paper in the emerging field of the cognitive study of early learning to program is Saeed Dehnadi et al.'s The Camel has Two Humps.
The study found that among programming students, three groups emerge: consistent thinkers, inconsistent thinkers, and people who refuse to answer any questions. The consistent group wasc haracterized by answering questions on aptitude and review tests consistently, while the inconsistent group was characterized by answering inconsistently. Similar studies were conducted among students studying formal logic with similar results.
Tests were conducted before and during introductory courses in programming and formal logic.
The authors make some sweeping and fairly controversial conclusions:
It has taken us some time to dare to believe in our own results. It now seems to us, although we are aware that at this point we do not have suﬃcient data, and so it must remain a speculation, that what distinguishes the three groups in the ﬁrst test is their diﬀerent attitudes to meaninglessness.
Formal logical proofs, and therefore programs – formal logical proofs that particular computations are possible, expressed in a formal system called a programming language – are utterly meaningless. To write a computer program you have to come to terms with this, to accept that whatever you might want the program to mean, the machine will blindly follow its meaningless rules and come to some meaningless conclusion. In the test the consistent group showed a pre-acceptance of this fact: they are capable of seeing mathematical calculation problems in terms of rules, and can follow those rules wheresoever they may lead. The inconsistent group, on the other hand, looks for meaning where it is not. The blank group knows that it is looking at meaninglessness, and refuses to deal with it.
The consistent group seem to be much easier to teach. We speculate that they divide into two groups: the very successful ones ﬁnd programming easy and may perhaps be those who ought to follow a conventional computer-science education, with lots of formal content; the moderately successful perhaps are the software engineers, those who can program but can’t imagine that they will ever enjoy it, and are content to submit to management discipline and to be drowned in UML (ugh!)
Sounds depressing. Everyone loves the Lockean idea of the tabula rasa. That's the underlying principle behind "No Child Left Behind", and why I've had so many people tell me "Anyone can learn X!"1 But it's wishful thinking - I know from personal experience whatever reason different people exhibit different aptitudes for mathematics and programming. Some people have no talent at all.
I think more research should be conducted here. Is meaningless rule-following consistency the proper test of early programming and mathematical aptitude? Or is there a better early indicator of success? Should students be screened before trying to teach them proofs or programming so teachers don't waste their time?
 This is inevitably followed by some advertisement to buy something that will teach me X.