Hacker’s Brain – The Psychology of Programming

A blog post on how programmers think. Tidbits:

Everybody in this country should learn to program a computer… because it teaches you how to think.

Nobody would argue with that.

This may be why brain imaging of programmers shows that programming relies more heavily on the language centres of the brain versus the areas associated with maths. Programmers will rely on the ventral lateral prefrontal cortex, alongside their working memory.

Something that will debated forever. That programming is more about language (words and such) than math is why I believe OOP continues to be so successful. Programming simply isn't math.

All this happened in my head. When I got home, I simply wrote out the code, copy and pasted some parts I couldn’t remember and ironed out the bugs until it worked smoothly. The actual hard part happened away from the computer in this case. You even ‘run’ the programs in your brain by following the logic through step by step to see if it would work – you can this way flag up bugs (gotta’ catch ‘em all!) before actually creating the code.

Programming environments aren't really optimized for thinking. It would be interesting to see if "thinking" and "programming" could be combined for a more augmented experience.

We use our working memory to store information, so when you’re imaging what a line of code does, you have to store the variables and the ideas you’re testing out, there. So when you’re thinking of a sequence of events, you need to keep the line of logical reasoning held in your working memory – which is where the similarity to math comes in.

...

Here’s also where things get more interesting still: because the brain areas involved with abstract thought are actually the same as those associated with verbal semantic processing (1). But then of course it does – language represents ideas just as code represents logic.

True, I wonder if our own internal working memory can be reflected back into the computer...again augmentation...this is the main point of live programming.

It’s probably down to the very immediate feedback loop that coding provides: the ability to test what you’ve written and immediately see the results is incredibly gratifying. Dopamine is the neurotransmitter that our brain releases in anticipation of reward and I’d argue coders have got dopamine to spare. This is the definition of ‘the work being its own reward’.

Again, there is great value in even better more immediate feedback loops. Feed the Dopamine! And ya, lots of caffeine.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Bias?

The provided link doesn't specify where the "maths" brain region is. [Edit] Correction, it mentions the Intraparietal_sulcus. However fwiw the wikipedia link does not confirm that this is the "maths" region.
Have these researchers heard of Curry/Howard or Montague?

There will always be bias in

There will always be bias in anything except pure numbers.

What they do find is that programmers rely more on regions that are similar to those used in language than those used in math when comprehending code. Of course, what those programs do is probably important, and it might always be the case that mathematical problem solving has occurred before the programmer starts writing code.

Work off of Chris Parnin's homepage (the author of the study) is also quite interesting. The specific paper mentioned in the article; abstract:

Program comprehension is an important cognitive process that inherently eludes direct measurement. Thus, researchers are struggling with providing suitable programming languages, tools, or coding conventions to support developers in their everyday work. In this paper, we explore whether functional magnetic resonance imaging (fMRI), which is well established in cognitive neuroscience, is feasible to soundly measure program comprehension. In a controlled experiment, we observed 17 participants inside an fMRI scanner while they were comprehending short source-code snippets, which we contrasted with locating syntax errors. We found a clear, distinct activation pattern of five brain regions, which are related to working memory, attention, and language processing—all processes that fit well to our understanding of program comprehension. Our results encourage us and, hopefully, other researchers to use fMRI in future studies to measure program comprehension and, in the long run, answer questions, such as: Can we predict whether someone will be an excellent programmer? How effective are new languages and tools for program understanding? How should we train programmers?

Theorem proving

There are lots of different kinds of tasks in mathematics. Proving theorems, in particular, I've found to be as its core the same task as programming.

That programming is more

That programming is more about language (words and such) than math is why I believe OOP continues to be so successful.

"Successful" is vague. There's no evidence that OO yields better solutions, there's only evidence that OO is more popular. But as we all know, popularity is not a proxy for superiority. It's more likely that OO is simply a lingua franca much like English is in most domains: not superior, but sufficient, and pervasive simply because it's already dominant and thus taught to all new programmers. OOP's success would then have little to do with how it structures nouns and verbs compared to how other languages structure nouns and verbs (nor do I see why such a structuring would be preferred by the brain's language centers -- it's certainly not common to all natural languages after all).

You also omitted the following article passage which qualifies your quote:

It makes sense that the language areas light up, only because programmers have to access their lexicon to read and write code. This isn’t where the ‘magic happens’ so to speak.

Translating abstract concepts to and from a language tautologically requires the language centers, not because this is where reasoning about programs actually happens.

It would be interesting to see if "thinking" and "programming" could be combined for a more augmented experience.

You don't consider programming to be math, but you do want to incorporate thinking, but math is distilled clear thinking, so you want to integrate math into programming?

From the article:

Rarely will you have to perform a ‘sum’ and if you do, you can just use a calculator – or even the programming language itself.

Sums and similar functions seem pretty common to me. They're pervasive in graphics obviously, but even standard business programs perform all sorts of querying and reporting.

"Successful" is vague.No

"Successful" is vague.

No argument there. I should have used the word popular. It is just more accessible because our brains make it easier than mentally training up to do hardcore math as functional programming (though programming in most FP languages probably isn't really math heavy either). I don't claim (and have never claimed actually) that it results in better programs (however that might be measured).

Translating abstract concepts to and from a language tautologically requires the language centers, not because this is where reasoning about programs actually happens.

Actually, our ability to abstract comes from our language centers. Our ability to do intense abstract reasoning (math) is built on top of that. But you can do the former (deal with abstractions) without delving into the latter.

You don't consider programming to be math, but you do want to incorporate thinking, but math is distilled clear thinking, so you want to integrate math into programming?

Programming involves math, many programs require heavy duty math. Programming itself is communication, and we can communicate lots of stuff. But ya, I would prefer programming to be a tool to do come up with solutions to problems rather than just encoding them, and when that involves math...code should be able to replace a white board.

The program I'm writing right at this minute is heavily involved in geometry (a live programming diagramming environment). It is definitely "math", but the actual writing out of code is rather mundane. Code doesn't help much in thinking, so I have a notepad right next to me, and spend much of my time there doing abstract reasoning. I would love to bring that into the programming environment (which is the whole point of the program I'm writing...but I digress).

Sums and similar functions seem pretty common to me. They're pervasive in graphics obviously, but even standard business programs perform all sorts of querying and reporting.

Programs are actually quite diverse in their domains. Hello world doesn't really involve much math, obviously. Many programs simply move data from point A to point B, and programmers spend most of their time finding out where A and B are.