What exactly happens when we read computer code? Some interesting research was recently funded to find out by the National Science Foundation, the Department of the Brain and Cognitive Sciences at Massachusetts Institute of Technology, and the McGovern Institute for Brain Research. Four researchers — three from MIT and one from Tufts University — performed MRI scans on the brains of dozens of participants performing “program comprehension tasks” in which they predicted a program’s output.
The idea was to determine how exactly computer code is comprehended in the brain — how the variables, function names, and keywords become meaningful expressions and then coalesce into a larger whole. Would there be clues for computer science educators — or even some tantalizing insights for the IT world’s developers? And perhaps most notably for computer programming instructors, it seeks to answer the question what part of the brain is most responsible for learning coding skills. Is it the part that does math? Or is it the part responsible for learning language?
Music, Math, and Language
The paper’s senior author, Evelina Fedorenko, has already been studying the question of whether the brain’s language network is used for other functions, according to an announcement from MIT, which notes that based on her previous work “music and math do not appear to activate this language network.” They also cite Anna Ivanova, an MIT graduate student and the lead author of the study, who explained this next area of exploration. “Here, we were interested in exploring the relationship between language and computer programming, partially because computer programming is such a new invention that we know that there couldn’t be any hardwired mechanisms that make us good programmers.”
Does the brain treat code like natural language? Or like logic and math? We addressed this question by measuring fMRI responses to two very different programming languages – Python and ScratchJr (graphical programming language for kids). 1/n
— Anna Ivanova (@neuranna) April 18, 2020
MIT’s announcement summarize the two schools of thought that Ivanova wanted to investigate. “One holds that in order to be good at programming, you must be good at math. The other suggests that because of the parallels between coding and language, language skills might be more relevant.”
Or, as the researchers explain in the resulting paper, “If code comprehension relies on the same circuits that map form to meaning in natural language, we expect to see activity within the language system” — though they were also studying a second possibility: the “multiple demand” brain regions used for solving complex problems.
“It does pretty much anything that’s cognitively challenging, that makes you think hard,” Ivanova explains in MIT’s announcement.
The researchers even watched responses to both Python code samples and also to the graphical programming language ScratchJr (which was developed by MIT’s Media Lab working in cooperation with Tufts University and The Playful Invention Company). Their research was conscientiously thorough, the paper explains. “In the Python experiment, we further examine two problem types (math problems and string manipulation) and three basic types of program structure (sequential statements, forloops, and if statements).” The Python tests involved 24 adult participants — 15 women — while the ScratchJr tests involved 19 adult participants — 12 women.
And the results? The researchers discovered that that “multiple demand” region was responding to both kinds of code — even the more visual graphical language. Meanwhile, the language-related region did respond to the sentence-based problems — “but weakly or not at all to code problems.” The final results are succinctly summarized in the paper’s title: “Comprehension of computer code relies primarily on domain-general executive brain regions.”
“Neuroscientists find that interpreting code activates a general-purpose brain network, but not language-processing centers,” clarifies the headline on an MIT news release.
“However, although reading computer code activates the multiple demand network, it appears to rely more on different parts of the network than math or logic problems do, suggesting that coding does not precisely replicate the cognitive demands of mathematics either.”
The study doesn’t rule out the involvement of other brain regions, notes MIT’s announcement. “The researchers say that while they didn’t identify any regions that appear to be exclusively devoted to programming, such specialized brain activity might develop in people who have much more coding experience.” But Fedorenko specified that at least with their study, “In people who are familiar with coding and can efficiently do these tasks, but have had relatively limited experience, it just doesn’t seem like you see any specialization yet.”
MIT also notes the paper was accompanied by a companion paper from Johns Hopkins University researchers that reached a similar conclusion “that solving code problems activates the multiple demand network rather than the language regions…” And this ultimately has ramifications for educators. As technology writer Clive Thompson puts it, “One reason the scientists are exploring this math/language question is because frankly, we’re pretty bad at teaching programming, and teaching computer science. Nobody quite knows: Do you approach it like math? Like language? Like… what, precisely?”
“Understanding computer code seems to be its own thing. It’s not the same as language, and it’s not the same as math and logic” — Anna Ivanova.
“This new finding reveals that to the human brain, the process of code comprehension is not the same as reading language,” notes an article in Psychology Today. “Based on the study results, from an education perspective, teaching computer coding like a foreign language may not be the most efficient approach.”
MIT points out, that “The findings suggest there isn’t a definitive answer to whether coding should be taught as a math-based skill or a language-based skill. In part, that’s because learning to program may draw on both language and multiple demand systems, even if — once learned — programming doesn’t rely on the language regions, the researchers say.”
Ivanova told them that “It looks like computer science educators will have to develop their own approaches for teaching code most effectively.”
But it’s been fun for her to watch the reactions from actual programmers.
Watching practitioners discuss your science is fun :)
They cover a lot of ground, including coding vs. foreign language learning, coding vs. music, coding vs. lawhttps://t.co/fQTEUH6ERW
— Anna Ivanova (@neuranna) December 16, 2020
“It definitely involves language processing,” argued one commenter at BoingBoing. “I had to get into some different music working as a programmer, because stuff with lyrics would short-circuit my concentration. I’d even find myself typing out the words I was hearing in the song.”
And in Reddit’s Science forum, MIT’s announcement attracted over 16,500 upvotes — and 464 comments.
One appreciative response came on Twitter from Microsoft cloud advocate Alvaro Videla that “As a dilettante, I can tell you that while I was planning to write a critique… this is the most serious, and nuanced paper I’ve read about the topic. It considers aspects of code that usually are overlooked. It recognizes its own limitations… So all in all, applause! If you are interested in Language and Programming, this paper is a must.”
Of course, there’s is ultimately one other possibility: that the brain may just remain a mystery. Clive Thompson concluded that “I’m excited to see what else emerges from this thread of neurological exploration, but I bet the final answer, if we get one, will be like everything else we’re learning about the brain: Crazy complex, super contingent, hard to generalize about.”
- DataDrivenDance: a ballet that interrogates computer science theory, as well as bioengineering, and digital ethics.
- Tech blogger’s big accomplishment in 2020: “logged all my activities at 15-minute intervals for the whole year.”
- What tech experts are predicting for the year 2021.
- A look back at half a century of text adventures.
- Chess pieces occupy two squares simultaneously in the world’s first tournament of quantum chess.
- How Phish spent New Year’s Eve playing a game of chess against thousands of fans.
- The 10 KB Club: a curated collection of websites whose home pages do not exceed 10 KB