Mulling over a computer program is not like thinking in everyday language—but it’s not pure logic either. Coding is becoming an increasingly vital skill. As more people learn how to code, neuroscientists are beginning to unlock the mystery behind what happens in people’s brain when they “think in code.”
“Computer programming is not an old skill, so we don’t have an innate module in the brain that does the processing for us,” says Anna Ivanova, a graduate student at MIT’s Department of Brain and Cognitive Sciences. “That means we have to use some of our existing neural systems to process code.”
Ivanova and her colleagues studied two brain systems that might be good candidates for processing code: The multiple demand system—which tends to be engaged in cognitively challenging tasks such as solving math problems or logical reasoning—and the language system. Despite the structural similarities between programming languages and natural languages, the researchers found that the brain does not engage the language system. it rather activates the multiple demand system.
The study also found that the multiple demand system likely stores representations of code-relevant information, including common coding concepts (such as loops) and knowledge specific to a programming language (such as the syntax of a for loop in Java versus Python).
Yet coding and math and logic don’t rely on entirely the same brain mechanisms. “The multiple demand system includes regions in the left and right hemispheres,” Ivanova says. “For math and logic, we usually see more activity in the left hemisphere. For code, it activated the multiple demand system in both hemispheres, so the activation pattern is different from what we see for math and logic.”
“Most people use their right hand to write, while some people use their left, and fewer people can use both hands. That might also be true for reading code,” Liu says. “Most people use the left logical reasoning system, and some use a bit of the right, but maybe some people use both. How much each individual relies on the left brain to read code is associated with how much they rely on the left brain to do linguistic tasks.”
While the MIT study didn’t identify any specialized region in the multiple demand system dedicated to interpreting code, Ivanova notes it’s possible to develop such a region as proficiency in programming grows. “Maybe if you’re extremely good, you will have some dedicated chunk of brain tissue for code. But you don’t need it to be a good programmer,” she says.
According to Ivanova, the benefits of studying the cognitive and neural foundations of coding are twofold. “We’ll have a more scientific basis to inform our understanding of the most effective way to teach programming,” she says. “And we can leverage the broader domain of cognitive science to figure out how we can design programming languages that are adapted to the specifics of the human brain.”