Here is a discussion of a paper (with link to the paper itself) that looks at these issues: http://www.tjradcliffe.com/?p=1338
And some follow-on, where I build a simple model that reproduces the biomodal mark distribution under the assumption that there is a single characteristic that is uniformly distributed amongst the population but that exhibits a threshold when it comes to programming: http://www.tjradcliffe.com/?p=1471
My bet is there's one (or a small number) of characteristics that are possessed in different degree by people and that if you fall below some threshold you will have a hard time learning to code. I liken this to height with respect to getting over a wall in an obstacle course: for people who are tall enough, it'll be easy. For people below some threshold it will become increasingly hard. There are two other variables that matter (strength and weight) so it may be difficult to pull out height as a single parameter, but some linear combination of height, weight and strength should be a good predictor of ability to get over the wall.
No one has found such a small set of factors for programming ability yet, but I'm not aware of anyone testing the things that are likely to be important, particularly a) ability to follow instructions; b) ability to create a set of instructions for a task that, when followed by a person unfamiliar with every element of the task will result in its successful completion; and c) ability to arbitrarily use anything to represent anything else.