Study finds brain-activity of people coding isn't quite like when they use language, or do math

When you do computer programming, what sort of mental work are you doing?

For a long time, folks have speculated on this. Since coding involves pondering hierarchies of symbols, maybe the mental work is kinda like writing or reading? Others have speculated it's more similar to the way our brains process math and puzzles.

A group of MIT neuroscientists recently did fMRI brain-scans of young adults while they were solving a small coding challenge using a textual programming language (Python) and a visual one (Scratch Jr.). The results?

The brain activity wasn't similar to when we process language. Instead, coding seems to activate the "multiple demand network," which — as the scientists note in a public-relations writeup of their work — "is also recruited for complex cognitive tasks such as solving math problems or crossword puzzles."

So, coding is more like doing math than processing language?

Sorrrrrrt of … but not exactly so. The scientists saw activity patterns that differ from those you'd see during math, too.

The upshot: Coding — in this (very preliminary!) work, anyway — looks to be a little different from either language or math. As they note, in a media release …

"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," says Anna Ivanova, an MIT graduate student and the lead author of the study. [snip]

The researchers saw little to no response to code in the language regions of the brain. Instead, they found that the coding task mainly activated the so-called multiple demand network. This network, whose activity is spread throughout the frontal and parietal lobes of the brain, is typically recruited for tasks that require holding many pieces of information in mind at once, and is responsible for our ability to perform a wide variety of mental tasks.

"It does pretty much anything that's cognitively challenging, that makes you think hard," Ivanova says.

Previous studies have shown that math and logic problems seem to rely mainly on the multiple demand regions in the left hemisphere, while tasks that involve spatial navigation activate the right hemisphere more than the left. The MIT team found that reading computer code appears to activate both the left and right sides of the multiple demand network, and ScratchJr activated the right side slightly more than the left. This finding goes against the hypothesis that math and coding rely on the same brain mechanisms.

Their original paper is here in full, and is quite an interesting read.

The usual caveats to this type of research apply, which include: The research subjects are probably "WEIRD", the meaning of neuroimaging results are filled with debate, this work is very new so you don't want to overinterpret it, the brain is ultra complex and rilly hard to understand.

There's some cultural freight here. 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? In the same vein, is it possible to identify what types of students might really dig it — what sorts of minds will resonate with its odd pleasures? Is it possible to figure out what types of intellectual pitfalls are likely, and how to bridge them?

Hence this sort of research. In theory, the more we know about what type of mental work programming is, the better we might be able to answer these questions.

Just anecdotally — having interviewed hundreds of coders and computer scientists for my book CODERS — I've met amazing programmers and computer scientists with all manner of intellectual makeups. There were math-heads, and there were people who practically counted on their fingers. There were programmers obsessed with — and eloquent in — language, and ones gently baffled by written and spoken communication. Lots of musicians, lots of folks who slid in via a love of art and visual design, then whose brains just seized excitedly on the mouthfeel of algorithms.

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.