In a way, learning to program a computer is similar to learning a new language. It requires learning new symbols and terms, which must be organized correctly to tell the computer what to do. The computer code should also be clear enough for other programmers to read and understand it.
Despite these similarities, MIT neuroscientists have found that reading computer code does not activate the brain regions involved in language processing. Instead, it activates a distributed network called a multi-demand network, which is also recruited for complex cognitive tasks such as solving math problems or crossword puzzles.
However, although reading computer code activates the network of multiple demands, it seems to depend more on different parts of the network than math or logic problems, suggesting that the coding does not accurately replicate the cognitive demands of mathematics.
“Understanding the computer code seems to be his thing. It’s not the same as language and it’s not the same as math and logic, ”says Anna Ivanova, an MIT graduate student and lead author of the study.
Evelina Fedorenko, associate professor of neuroscience at Frederick A. and Carole J. Middleton for career development and a member of the McGovern Institute for Brain Research, is the lead author of the paper, which appears today in eLife. Researchers from MIT’s Computer Science and Artificial Intelligence Laboratory and Tufts University also participated in the study.
Language and cognition
One of the main focuses of Fedorenko’s research is the relationship between language and other cognitive functions. In particular, he has been studying the question of whether other functions depend on the brain language network, which includes the Broca area and other regions of the left hemisphere of the brain. In previous work, his laboratory has shown that music and mathematics do not seem to activate this network of languages.
“Here we were interested in exploring the relationship between language and computer programming, in part because computer programming is such a new invention that we know there could be no connected mechanisms that make us good programmers,” says Ivanova.
There are two schools of thought on how the brain learns to code, she says. One argues that to be good at programming, you have to be good at math. The other suggests that because of the parallels between coding and language, language skills may be more relevant. To shed light on this topic, the researchers set out to study whether patterns of brain activity when reading computer code would overlap with language-related brain activity.
The two programming languages the researchers focused on in this study are known for their readability: Python and ScratchJr, a visual programming language designed for children ages 5 and up. The subjects in the study were young adults proficient in the language in which they were being tested. While the programmers were on a functional magnetic resonance imaging (fMRI) scanner, the researchers showed them code snippets and asked them to predict what action the code would produce.
The researchers saw little or no response to the code in the linguistic regions of the brain. Instead, they found that the coding task primarily activated the so-called multiple-demand network. This network, whose activity extends to the frontal and parietal lobes of the brain, is usually recruited for tasks that require keeping a lot of information in mind at once and is responsible for our ability to perform a variety of mental tasks.
“It does almost anything that is cognitively challenging, that makes you think a lot,” Ivanova says.
Previous studies have shown that math and logic problems appear to depend primarily on the multiple demand regions of the left hemisphere, while tasks involving space navigation activate the right hemisphere rather than the left. The MIT team found that reading the computer code seemed to activate the left and right sides of the multi-demand network and ScratchJr activated the right side a little more than the left. This finding goes against the hypothesis that mathematics and coding are based on the same brain mechanisms.
Effects of experience
The researchers say that while they did not identify any region that appears to be devoted exclusively to programming, this specialized brain activity could develop in people with much more coding experience.
“It’s possible that if you take people who are professional programmers, who have been coding in a particular language for 30 or 40 years, you start to see some specialization or some crystallization of parts of the multi-demand system,” Fedorenko says. “In people who are familiar with coding and can do these tasks efficiently, but who have relatively limited experience, it seems like you still don’t see any specialization.”
In a supplementary article that appears in the same issue of eLife, a team of researchers at Johns Hopkins University also reported that code troubleshooting activates the network of multiple demands rather than language regions.
The findings suggest that there is no definitive answer as to whether coding should be taught as a math-based skill or a language-based skill. In part, this is because learning to program can be based on both language systems and multiple-demand systems, even if, once learned, programming does not depend on language regions, the researchers say.
“There have been claims from both camps: it has to be alongside math, it has to be alongside language,” Ivanova says. “But it looks like computer educators will need to develop their own approaches to teaching code more effectively.”
The research was funded by the National Science Foundation, the MIT Department of Brain and Cognitive Sciences and the McGovern Institute for Brain Research.