Ethan Mollick brought this Nature article to my attention. One of the authors Chantel Prat, is also on the thread.
The sample size for this study is only 36, so we should think of it as preliminary work toward understanding how people learn to program.
Their abstract, with emphasis added by me:
This experiment employed an individual differences approach to test the hypothesis that learning modern programming languages resembles second “natural” language learning in adulthood. Behavioral and neural (resting-state EEG) indices of language aptitude were used along with numeracy and fluid cognitive measures (e.g., fluid reasoning, working memory, inhibitory control) as predictors. Rate of learning, programming accuracy, and post-test declarative knowledge were used as outcome measures in 36 individuals who participated in ten 45-minute Python training sessions. The resulting models explained 50–72% of the variance in learning outcomes, with language aptitude measures explaining significant variance in each outcome even when the other factors competed for variance. Across outcome variables, fluid reasoning and working-memory capacity explained 34% of the variance, followed by language aptitude (17%), resting-state EEG power in beta and low-gamma bands (10%), and numeracy (2%). These results provide a novel framework for understanding programming aptitude, suggesting that the importance of numeracy may be overestimated in modern programming education environments.
Learning Python, at least at first, is more like learning a foreign natural language than it is like doing arithmetic problems.
There are still many open questions in this area, so I see this paper as an important small step in the right direction. I have also done a study on this topic.
This resonates with my personal experience. I am good at math, but so-so at foreign languages. I can learn them, but only with laborious effort. And likewise, I can do accurate programming, but am really slow at grinding out the code. But I know people who can just sit down and pump out pages of code on the spot.