You May Be Better at Learning to Code Than You Think – Even if You’re Not a “Math Person”

Brain Activity While Coding

Language skills are a stronger predictor of programming ability than math knowledge, according to a new University of Washington study. Here, study co-author Malayka Mottarella demonstrates coding in Python while wearing a specialized headset that measures electrical activity in the brain. Credit: Justin Abernethy/U. of Washington

Want to learn to code? Put down the math book. Practice those communication skills instead.

New research from the University of Washington finds that a natural aptitude for learning languages is a stronger predictor of learning to program than basic math knowledge, or numeracy. That’s because writing code also involves learning a second language, the ability to learn that language’s vocabulary and grammar, and how they work together to communicate ideas and intentions. Other cognitive functions tied to both areas, such as problem-solving and the use of working memory, also play key roles.

“Many barriers to programming, from prerequisite courses to stereotypes of what a good programmer looks like, are centered around the idea that programming relies heavily on math abilities, and that idea is not born out in our data,” said lead author Chantel Prat, an associate professor of psychology at the UW and at the Institute for Learning & Brain Sciences. “Learning to program is hard, but is increasingly important for obtaining skilled positions in the workforce. Information about what it takes to be good at programming is critically missing in a field that has been notoriously slow in closing the gender gap.”

Different Skills Contribute to Learning Python

This graph shows how the skills of study participants, such as numeracy and language aptitude, contribute to the learning of Python. According to the graph, cognition and language aptitude are greater predictors of learning than numeracy. Credit: Prat et al./Scientific Reports

Published online March 2 in Scientific Reports, an open-access journal from the Nature Publishing Group, the research examined the neurocognitive abilities of more than three dozen adults as they learned Python, a common programming language. Following a battery of tests to assess their executive function, language, and math skills, participants completed a series of online lessons and quizzes in Python. Those who learned Python faster, and with greater accuracy, tended to have a mix of strong problem-solving and language abilities.

In today’s STEM-focused world, learning to code opens up a variety of possibilities for jobs and extended education. Coding is associated with math and engineering; college-level programming courses tend to require advanced math to enroll and they tend to be taught in computer science and engineering departments. Other research, namely from UW psychology professor Sapna Cheryan, has shown that such requirements and perceptions of coding reinforce stereotypes about programming as a masculine field, potentially discouraging women from pursuing it.

But coding also has a foundation in human language: Programming involves creating meaning by stringing symbols together in rule-based ways.

Though a few studies have touched on the cognitive links between language learning and computer programming, some of the data is decades old, using languages such as Pascal that are now out of date, and none of them used natural language aptitude measures to predict individual differences in learning to program.

So Prat, who specializes in the neural and cognitive predictors of learning human languages, set out to explore the individual differences in how people learn Python. Python was a natural choice, Prat explained, because it resembles English structures such as paragraph indentation and uses many real words rather than symbols for functions.

To evaluate the neural and cognitive characteristics of “programming aptitude,” Prat studied a group of native English speakers between the ages of 18 and 35 who had never learned to code.

Before learning to code, participants took two completely different types of assessments. First, participants underwent a five-minute electroencephalography scan, which recorded the electrical activity of their brains as they relaxed with their eyes closed. In previous research, Prat showed that patterns of neural activity while the brain is at rest can predict up to 60% of the variability in the speed with which someone can learn a second language (in that case, French).

“Ultimately, these resting-state brain metrics might be used as culture-free measures of how someone learns,” Prat said.

Then the participants took eight different tests: one that specifically covered numeracy; one that measured language aptitude; and others that assessed attention, problem-solving, and memory.

To learn Python, the participants were assigned 10 45-minute online instruction sessions using the Codeacademy educational tool. Each session focused on a coding concept, such as lists or if/then conditions, and concluded with a quiz that a user needed to pass in order to progress to the next session. For help, users could turn to a “hint” button, an informational blog from past users, and a “solution” button, in that order.

From a shared mirror screen, a researcher followed along with each participant and was able to calculate their “learning rate,” or speed with which they mastered each lesson, as well as their quiz accuracy and the number of times they asked for help.

After completing the sessions, participants took a multiple-choice test on the purpose of functions (the vocabulary of Python) and the structure of coding (the grammar of Python). For their final task, they programmed a game — Rock, Paper, Scissors — considered an introductory project for a new Python coder. This helped assess their ability to write code using the information they had learned.

Ultimately, researchers found that scores from the language aptitude test were the strongest predictors of participants’ learning rate in Python. Scores from tests in numeracy and fluid reasoning were also associated with Python learning rate, but each of these factors explained less variance than language aptitude did.

Presented another way, across learning outcomes, participants’ language aptitude, fluid reasoning and working memory, and resting-state brain activity were all greater predictors of Python learning than was numeracy, which explained an average of 2% of the differences between people. Importantly, Prat also found that the same characteristics of resting-state brain data that previously explained how quickly someone would learn to speak French, also explained how quickly they would learn to code in Python.

“This is the first study to link both the neural and cognitive predictors of natural language aptitude to individual differences in learning programming languages. We were able to explain over 70% of the variability in how quickly different people learn to program in Python, and only a small fraction of that amount was related to numeracy,” Prat said. Further research could examine the connections between language aptitude and programming instruction in a classroom setting, or with more complex languages such as Java, or with more complicated tasks to demonstrate coding proficiency, Prat said.

Reference: “Relating Natural Language Aptitude to Individual Differences in Learning Programming Languages” by Chantel S. Prat, Tara M. Madhyastha, Malayka J. Mottarella and Chu-Hsuan Kuo, 2 March 2020, Scientific Reports.
DOI: 10.1038/s41598-020-60661-8

The study was funded by the Office of Naval Research. Additional co-authors were Tara Madhyastha, a computer scientist and former research assistant professor in the UW Department of Radiology; and Chu-Hsuan Kuo and Malayka Mottarella, graduate students in the UW Department of Psychology and at I-LABS.

5 Comments on "You May Be Better at Learning to Code Than You Think – Even if You’re Not a “Math Person”"

  1. As I am an SEO Analyst I always show interest in technical side and learning python more accurately. As a learner I find encouragement in your article and helpful information. Thanks for sharing useful information.

  2. forever a student | April 12, 2020 at 10:31 am | Reply

    This is no surprise to me. See:
    Lakoff & Núñez (2000) “Where Mathematics Comes From – How the Embodied Mind Brings Mathematics Into Being”
    I found this thread of info as a layman student of cognitive science psychology. Other books with Lakoff as (co-)author expound on this concept. I found the following book to be one of the most important books in understanding what it means to be a human:
    Lakoff (1987) “Women, Fire, and Dangerous Things – What Categories Reveal about the Mind”

  3. The thing is this analysis was done with a trivial coding task and on people that didn’t know how to code.

    We know that in most fields, expert don’t necessarily use the same area of the brain. Also I think different skillset are required for coding depending of what you code. Finally coding is only one part of the job.

    Basically good developpers are focus on the details as well as on the big picture. They have solid logical reasoning skills and are good team players.

    You don’t need a high level in math, but you really need the logic and understand of mathematical concepts at a decent level.

    Entry university level for math is likely enough for programming in general but if you go in many fields (image processing, machine learning, finance/insurance, search engines…) you’ll benefit a lot from a bachelor level in math and science.

    • An understanding of architecture and building with purpose are extremely beneficial, but even if you go into image processing or finance/insurance, the level of math is going to be very disappointing. Helpful, maybe, since your spatial reasoning is built up to do rough calculus on the fly, but even balancing your checkbook is more demanding when it comes to the code’s math requirements.

      Discrete math can be good if you’re writing drivers or going to lower levels than RTOS on PLCs, and linear algebra can help with DSP, but hard math’s still a no-show unless you’re doing applied engineering in ECUs or avionics, or industrial control systems.

  4. Cliche exercises like “tell me how to make a peanut butter & jelly sandwich” are better at honing and testing coding ability than math.

Leave a comment

Email address is optional. If provided, your email will not be published or shared.