Is programming more like natural language or mathematics? A recent article from Ars Technica throws some water on both camps. In How does the brain interpret computer languages?, Ars looks at some science: the story so far is that it’s some of both but also its own thing entirely.
Did python skew the result?
I have to wonder if python was the best choice for the experiments. Sure it’s everywhere thanks to our current obsession with data science, and I’m always suggesting it as a first language for beginners or software-adjacent careers like technical managers or spreadsheet addicts. Despite looking more like pseudo-code, “readability” does not make it the most expressive programming language, so it may not tickle the language centers of the brain as much as (ahem) other languages.
Perl is a much more expressive language. Creator Larry Wall has some very strong feelings on how programming language designers should take cues from natural languages. I came to perl from C, and the freedom to say exactly what I meant was intoxicating after working within the constraints of a minimalist language with 17 reserved words. My code started to look more like how I thought about the problems I was solving.
Python’s grown more flexible with age (unlike me), but there is still a philosophy that there’s a best way to do something, the pythonic way. Compare that to perl’s motto there’s more than one way to do it: there’s more than one way to achieve the same functional outcome that expresses the programmer’s understanding of the problem. Consider this example:
use v5.030;
my $x = 5;
if ($x > 3) { say "Yes to the test 1!"; }
unless ($x > 9) { say "Yes to the test 2!"; }
say "Yes to the test 3!" if $x > 3;
These three statements all do the same thing. Compared to the first, using unless
implies the condition is unlikely and can also eliminate the syntactic salt of an if (! something)
construct. The condition at the end of the statement focuses attention on what’s to be done rather than if it should be done. All three are functionally the same to the interpreter but express something different to programmers reading the code.
Abby who?
The other language used in the studies did yield different results, but ScratchJr isn’t big in writing fintech applications or printer drivers. The next thing I would like to see studied is a more apples-to-apples comparison of programming languages used to solve–to translate–real world problems into digital solutions. If they discover real differences between how our brains deal with different commercial languages, I wonder if more language designers will consider cognitive load and semantic flexibility alongside the normal functional considerations.
One particular area I’d loved to see studied is if object-oriented, procedural, and functional programming languages have different cognitive profiles. It’s become cool to hate OOP, and I think some of that hate is deserved. Inheritance in particular is easy to abuse, and Google didn’t even bother trying to support it in Go. One rationale for OOP is that we live in a real world of objects, so it should be easier to write programs using that metaphor. Good on paper, but it doesn’t feel like it lived up to that promise. Time to stick a bunch of programmers in fMRIs and see if particular language types do better in brains.
Programming isn’t for everybody, something this line of inquiry may be able to quantify. Is the idea of making all K-12 students take programming courses really a good idea? While I like the idea of everybody having the opportunity to discover a new talent or passion, I have my doubts. What is needed right now is more technology competency. Knowing some programming isn’t going to prevent hackers from stealing your credit card number or save you from radicalization by social media recommendation algorithms. Are we selling parents and kids a realistic career path, or is this just the myth perpetuated by startup culture and fly-by-night bootcamps? Remember in the late 1990s when “HTML Programmer” was an actual job title?
Sometimes I feel like it takes a complimentary set of neuroses to be a good programmer. A normal brain might just be too interested in real-world things to burn enough CPU cycles to be good at and enjoy coding. Maybe an abnormal brain is what we need for this, and maybe these studies will help us understand that. Of course, an abnormal brain is not always a good thing…