Slashdot Mirror


The Neuroscience of Computer Programming

Hugh Pickens DOT Com writes "Chris Parnin has an interesting read about an international team of scientists lead by Dr. Janet Siegmund using brain imaging with fMRI to understand the programmer's mind and to compare and contrast different cognitive tasks used in programming by analyzing differences in brain locations that are activated by different tasks. One recent debate illuminated by their studies is recent legislation that considers offering foreign-language credits for students learning programming languages. There have been many strong reactions across the software-developer community. Some developers consider the effort laudable but misguided and proclaim programming is not at all like human language and is much closer to mathematics. Siegmund observed 17 participants inside an fMRI scanner while they were comprehending short source-code snippets and found a clear, distinct activation pattern of five brain regions, which are related to language processing, working memory, and attention. The programmers in the study recruited parts of the brain typically associated with language processing and verbal oriented processing (ventral lateral prefrontal cortex). At least for the simple code snippets presented, programmers could use existing language regions of the brain to understand code without requiring more complex mental models to be constructed and manipulated." (Read on for more.) "Interestingly, even though there was code that involve mathematical operations, conditionals, and loop iteration, for these particular tasks, programming had less in common with mathematics and more in common with language (PDF)," writes Parnin. "Mathematical calculations typically take place in the intraparietal sulcus, mathematical reasoning in the right frontal pole, and logical reasoning in the left frontal pole. These areas were not strongly activated in comprehending source code." The new research results are a much needed, but only a first step in revealing the neuroscience of programming. Other questions remain including: Can we finally provide a neurological basis for a programmer's flow? How relevant is the mastery of language skills for programming? Are there certain programming activities that should never be mixed, due to higher chance of cognitive failure (and resulting bugs)? Do code visualizations or live programming environments really reduce mental load? "Programming involves a rich set of cognitive processes," concludes Parnin. "Although the study found a particular pathway that was strongly associated with language processing, there may be other pathways associated with other common activities related to programming (debugging, editing, refactoring, etc).""

35 of 161 comments (clear)

  1. Reading vs writing by Anonymous Coward · · Score: 5, Insightful

    In my experience, coding and reading other's code are two completely different tasks.

    1. Re:Reading vs writing by SunTzuWarmaster · · Score: 4, Insightful

      In this case, reading, writing, listening, and speaking a foreign language should all be different tasks. The neuroscience doesn't lie: the region of the language processing center lights up; portions of programming are similar to foreign languages.

    2. Re: Reading vs writing by aristotle-dude · · Score: 4, Insightful

      The article claimed that programming activated regions of the brain associated with language, not foreign language. Most programming languages they I've seen are in English. If you are a native English speaker, I don't see how this would count as a foreign language. If you are not a native English speaker, I suppose it could count as a really basic English credit.

      I think you are confused. Since I assume that you are a native english speaker and a monolingual one at that, I can understand how you have trouble with this concept. While most programming languages might have "keywords" written in english, they have a distinct syntax that is not exactly the same as natural english syntax which is why it is like thinking/reading in a different language than you are used to.

      --
      Jesus was a compassionate social conservative who called individuals to sin no more.
    3. Re:Reading vs writing by Anonymous Coward · · Score: 2, Insightful

      Stupid study.

      Hey guys! Reading written statements (code) uses language centres of the brain - well fuck-de-doo.

    4. Re: Reading vs writing by Immerman · · Score: 4, Interesting

      Indeed. Most Americans would probably find it straining to listen to someone speaking using English vocabulary but German grammar for extended periods. To say nothing of Latin. Even though the words are the same, the way they are organized to express concepts are quite different. I think most anyone who is both multilingual and accustomed to "watching" their own mind can attest to the fact that learning to truly think in a fundamentally different language doesn't just change the words you use, it also subtly changes the way you think about things.

      --
      --- Most topics have many sides worth arguing, allow me to take one opposite you.
    5. Re:Reading vs writing by Hognoxious · · Score: 3, Insightful

      The good part is where the programmers just know that it can't be so.

      MRI? No idea what it is. But if it contradicts my preconceptions that:

      a) mathematicians are smarter than literature types
      and
      b) I'm really really smart
      so
      c) what I do must be more like the former
      . . .
      then it's phrenology by a different name.

      --
      Confucius say, "Find worm in apple - bad. Find half a worm - worse."
    6. Re:Reading vs writing by Half-pint+HAL · · Score: 2

      You missed the point by an enormous margin. Writing code is absolutely nothing like writing words because the act of writing has relatively little to do with the act of constructing the things to be written (and the former takes up much less time than the latter in most cases).

      "Absolutely nothing" is a gross overstatement.

      I've been doing a lot of coding recently, and it just so happens that what I'm coding is language learning software (I have degrees both in Comp Sci and in modern languages).

      I would say that I reach what appears to be a "flow state" once I internally understand the logic of the task at hand completely. At that point, I am working linguistically -- I am expressing my thoughts in a codified form. The point where coding becomes non-linguistic is when I have to work out what the logic of the task is. That's a task that's carried out as I pace around in front of a window, as I chew on my lunch, as I soak in the bathtub....

      That coding is in part linguistic should come as no surprise (I can't be the only guy who mentally says to himself "is equal to" to remind myself to use a double-equals sign rather than a single one), but the problem seems to be that they're only measuring part of the process and avoiding the difficult bit. Here's one of their comprehension tasks:

      public static void main(String[] args) { String word = "Hello"; String result = new String(); for (int j = word.length() - 1; j >= 0; j--) result = result + word.charAt(j); System.out.println(result); }

      Now I'm not sure whether that's C++ or Java (or could it be C#?) but I understand it, even though I do not program in any of those languages. It uses the most common constructs of the language, with explicit naming conventions. It doesn't call for understanding of tail recursions or analysing structures or any of the stuff that actually makes for useful software.

      So they say this doesn't use the same bits of the brain that are involved in maths reasoning, but I doubt that they're comparing it with something as trivial as 2+2. Anyone who works with figures habitually doesn't have to "reason" or "calculate" 2+2 -- they know it automatically.

      --
      Got them moderator blues I blieve I walk out the do', With these mod-points I been gettin', I 'most never post no mo'
    7. Re: Reading vs writing by gregor-e · · Score: 2

      I find that music interferes with reading either English or code, but it helps me focus when I'm writing code. To me this suggests language input processing shares some of the parts of my mind used for listening to music, but crafting new code does not.

  2. I don't agree that coding is more like math by IgnorantMotherFucker · · Score: 5, Insightful

    For quite a long time now, I've been explaining to everyone who will sit still long enough to listen that the term "computer" is a bad name for what these boxen do.

    While strictly speaking they do carry out mathematical operations, that's not what most people use them for. They got the name "computer" because one of the earliest uses of computers was the numerical solution of differential equations. For example the Von Neumann architecture was developed by Dr. Von Neumann for use in designing hydrogen bombs. The Difference Engine was Charles Babbage's fat defense contract for the purpose of calculating firing tables, that is, how to aim a cannon, taking into account the wind and so on.

    Really these boxen are instruction following machines. I was able to finally explain to my mother what I really do, and what a programming language really is, by asking her to compare her applications that I might have written, to her writing down the recipe for chocolate chip cookies. That recipe could be written in English, or in German or what have you. English and German could then be taken to be recipe languages, much as Java and C++ can be considered programming languages.

    Why just the other day, I told a good friend that I wanted to return to graduate school to complete my Physics Doctorate, but had forgotten all my math. This because it is exceedingly uncommon for programmers to need to know much more than very basic arithmetic on the job. It is actually uncommon for me to use floating point on the job, or fractions. I cannot recall the last time I used a trigonometric function on the job.

    However coders do need very strong verbal reasoning skills. If you could win on the debating team, or you studied philosophy in college, I assert you could be a good coder.

    --
    Please mail me URLs of software employers.
    1. Re:I don't agree that coding is more like math by ebno-10db · · Score: 2

      Just because the skills and brain activity of reading and writing code is more akin to math, doesn't mean the required knowledge is identical to math.

    2. Re:I don't agree that coding is more like math by NapalmV · · Score: 2

      Why just the other day, I told a good friend that I wanted to return to graduate school to complete my Physics Doctorate, but had forgotten all my math. This because it is exceedingly uncommon for programmers to need to know much more than very basic arithmetic on the job. It is actually uncommon for me to use floating point on the job, or fractions. I cannot recall the last time I used a trigonometric function on the job.

      Oh well. You must have been in "enterprise computing". Where about any "application" is nothing but some sort of front end to one or more databases.

      But I have some good news for you. There are a few jobs in "scientific computing" where you would need all your math. Unfortunately they are rather scarce and don't pay that well either. But if you're after "intellectual challenge" they're pretty entertaining - they're definitely not "code monkey" style.

    3. Re:I don't agree that coding is more like math by Ateocinico · · Score: 3, Interesting

      Perhaps they hold the name of their first use. In France and Spain computers are called sorters, "ordinateur" and "ordenador" respectively. In those countries they'r spread started with services like banking and accounting.

    4. Re:I don't agree that coding is more like math by Capt.Albatross · · Score: 3, Insightful

      While strictly speaking [computers] do carry out mathematical operations, that's not what most people use them for.

      But calculation is not mathematics, either - or, more precisely, it is not mathematics as practiced by mathematicians doing mathematics. Calculation is what scientists, engineers, econometricians and so forth do when they apply the results of mathematics to issues in their own fields.

      I agree that the current practice of programming is not much like either of these things. Where mathematics (in the applied sense) plays an important part in the development of software (e.g. cryptography, signal processing), the mathematics is generally applied to the problem before coding starts.

    5. Re:I don't agree that coding is more like math by w_dragon · · Score: 2

      There aren't many fields that use more than 2-3 branches of math. Programming tends to use formal logic, lambda calculus, and graph theory. I never understood why people here think math ends at calculus and statistics.

    6. Re:I don't agree that coding is more like math by ranton · · Score: 3, Informative

      As another poster already mentioned, you are confusing your problem domain with programming. Your argument is little different than someone saying programming requires a significant amount of accounting knowledge just because they work for Intuit.

      Programming itself rarely includes more math than simple algebra. There are of course very specialized fields of software engineering that need quite a bit of math, such as data science or other research oriented fields. But at the risk of making up statistics, I doubt more than 5% of programmers use more than a 10th grade level of math in their entire career.

      And regardless of your young and naive view of the software development industry, writing line of business software is rarely just a front end to a database. That may be true for many SMB projects, but things are much different at the enterprise level. I have done research in academia and have helped design global software systems used by millions of users in almost a dozen countries, and I can say the level of complexity can be just as high in either specialty. One field does require a lot more math though.

      --
      -- All that is necessary for the triumph of evil is that good men do nothing. -- Edmund Burke
    7. Re:I don't agree that coding is more like math by NapalmV · · Score: 2

      As another poster already mentioned, you are confusing your problem domain with programming. Your argument is little different than someone saying programming requires a significant amount of accounting knowledge just because they work for Intuit.

      You got it right, that's exactly what I was saying: if you want to use your advanced maths then find a domain that uses them in addition to using a programming language. Coming back to the actually unnecessary complexity of "enterprise" software, here's how we got there:

      - people with no knowledge of maths, programming and systems theory were put in charge to draft the specs (yes, I'm talking business analysts and managers of all sorts) from platform selection to the minute details of the UI
      - developers were treated by said management like disposable cattle, with a "my way or the highway" attitude, to make sure that no real feedback could ever occur

      In the end, we got the most extraordinary kludges on workarounds of hacks improvised late nights between coke cans and pizza boxes. At the limits of what mankind could ever do.

    8. Re:I don't agree that coding is more like math by kumanopuusan · · Score: 2

      I'm glad there are a few people here who recognize this. Mathematics requires computation, but since its inception in Greek geometry that has never been the focus of the subject. Writing proofs is almost exactly like writing code, and it's not a coincidence.

      --
      Use of the words "good", "bad" or "evil" is almost invariably the result of oversimplification.
  3. Re:Balderdash by Anonymous Coward · · Score: 2, Interesting

    Well, I know myself. I believe the results in this study are obvious. Most of the time reading code involves parsing which is essentially a linguistic task. Mathematical thought might be more active in specific code sections but language will still account for 99.9% of your mental work. Writing code is probably the same or even more skewed towards language. Of course, I am assuming most people think before sitting down to write code.

  4. Re:Why? by Ardyvee · · Score: 2

    It prepares you for jobs because it's not uncommon you will have to deal with people who don't speak your native language. It's also not uncommon for people to move somewhere else because of a job. In non-english countries, it's in your best interest to teach your students english because a lot of information is available in that language.

    --
    I don't care if I'm wrong. I only care about everyone obtaining something from the discussion.
  5. Perl, Larry Wall, and Linguistics by theodp · · Score: 4, Interesting

    Larry Wall: Wall developed the Perl interpreter and language while working for System Development Corporation, which later became part of Unisys.[5] He is the co-author of Programming Perl (often referred to as the Camel Book and published by O'Reilly), which is the definitive resource for Perl programmers; and edited the Perl Cookbook. He then became employed full-time by O'Reilly Media to further develop Perl and write books on the subject.[5]

    Wall's training as a linguist is apparent in his books, interviews, and lectures. He often compares Perl to a natural language and explains his decisions in Perl's design with linguistic rationale. He also often uses linguistic terms for Perl language constructs, so instead of traditional terms such as "variable", "function", and "accessor" he sometimes says "noun", "verb", and "topicalizer".

    1. Re:Perl, Larry Wall, and Linguistics by Anonymous Coward · · Score: 5, Funny

      May I ask you to stick to the subject. We are talking about reading code. Everybody knows perl is a write only language.

  6. Makes sense to me... by Anonymous Coward · · Score: 4, Insightful

    Make sense to me... Language processing areas of the brain are a component of programming.

    Try this experiment: Count backward from 100 by 3s. As in 100, 97, 94, 91, 88, etc.

    At around 85 have another person -- yes an actual living breathing person -- start calling out random numbers between 1 and 100. See how long you can keep counting.

    It's all pure math. But very few people have the ability to keep going amid distractions, even when the numbers are being called out in a foreign language they do not speak or understand.

    Programming is like counting backward from 100 by 3s, only thousands of times more complex. Coding while someone is talking nearby can be downright impossible. Clearly there is some overlap between language processing and writing/reading/understanding code.

  7. Re:Why? by ledow · · Score: 4, Interesting

    Sorry, but it's much more deep-rooted than being able to talk to someone in a foreign country.

    If you don't get that, you probably don't have many bi-lingual friends and certainly haven't asked them about it.

    Being bi-lingual allows you to find patterns, origins, etymologies and structures of words. It's not uncommon from being able to speak French and English to being able to understand Spanish, Italian and maybe a little Portuguese WITHOUT having to learn anything, just hearing a native speaker.

    It's provides much greater command of grammar and language structure than is available in English alone.

    I speak as someone who was forced to learn only "tourist" German in an English school, who now lives with an Italian fluent in English and has entire swathes of friends who speak foreign languages.

    English is universally derided among them for being the easiest to learn. The grammar is pathetic. The rules are arbitrary but easily picked up. The words all comes from Latin or Greek or Germanic originally.

    And being bi-lingual opens up the creative areas of the brain associated with language. While you're 3-7 years of age, your brain will accept another language with ease. It won't even hinder you learning other things as you learn it. And you'll be bi-lingual by the time you're an adult with no extraneous effort. However, if you don't get it into the language-processing areas of the brain by that age, you will GREATLY struggle to learn a language later.

    And by learning a language, I mean being able to live normally in the country for a year without resorting to translation tools, not asking the way to the airport in a single, broken accent.

    My girlfriend's command of multiple languages is impressive. And it comes about because she was taught English in school and it was SO MUCH easier a language to learn than her own. It's basically the baby-language of foreign languages.

    It's not about tourism.
    It's not about being able to phone up a foreign company and sell to them.
    It's literally an expansion of your whole thought processes and language interpretation that allows you a much richer method of communication, no matter what the language.

    And while you're a child, you'll just absorb it - like any child in a bi-lingual home. But when you grow up, you'll struggle and have to spend 10 years learning to get the grammar, accent, structure, phrasing and wording correct enough to blend in. And it will never be "natural". But, learning a foreign language in school, it can be "natural" to your thought processes.

    They say you know when you've actually learned a language because you dream in it. That's how natural it becomes and you get the richness of expression available from all the languages you know.

    It's not about whether you know Perl, or French. It's about being able to genericise concepts enough that even when speaking in several languages at once you get a deeper understanding of what the grammar means and how the structure should be to be common to all languages.

    Someone who programs professionally in a range of programming languages will, generally speaking, be more fluent in any particular one. The same as someone who speaks more than one language being, generally speaking, more capable with their use of language overall.

  8. Programming is about goals and organisation by Alain+Williams · · Score: 2

    A lot of programming is about understanding a problem, seeing what the real needs are - not the ones that the users think they need. You then need strategic planning on how to meet those needs, a lot of that will be about understanding how the new program will fit into the existing ecosystem. Next comes the translation of that strategy into a programming language (or more: you may also need some SQL, HTML, shell, ...) and the completely different skills of debugging. Finally: documentation for the users and also the programmers [actually: I find that doing the first draft of the documentation before writing the code is a really good idea].

    So: programming is much more than just language skills.

    Some here have asserted that programming is a branch of maths. This may be true for some sorts of programs (or some subroutines), but it is not true for most of what I do -- although an understanding of maths does help some parts.

    Summary: please don't be simplistic, programming is a complex skill that requires many different brain subsystems, language is just one of them.

  9. Programming is a form of writing by CaroKann · · Score: 2

    I've always felt that writing good code is very similar to writing a good essay or research paper. The process is about the same. The thinking is about the same. The ideal steps followed to produce a decent paper are similar to the steps followed to produce decent code.

    I've always thought that a good essay writer can make a good programmer. In particular, good essay writers can make good programmer/analysts or project managers. In both worlds, you struggle with scope, organization, and fact finding. Answering the question "What is this paper/program really and truly about?" is the primary task.

  10. I found they were for me by NotSoHeavyD3 · · Score: 4, Interesting

    Since in college I was hopeless in my foreign language class when listening/speaking were stressed. (And failed those classes multiple times.) When all I had to do was read it(at the same 4th semester level) I passed it the first time and I wasn't even close to failing. (Yes, I realize this is an anecdote but I wouldn't be surprised if there were a difference between reading and listening.)

    --
    Did you know 80 to 90% of the moderators on slashdot wouldn't recognize a troll even if one dragged them under a bridge.
    1. Re:I found they were for me by BlackHawk-666 · · Score: 2

      I'm similar. While I can read French to a reasonable degree my ability to understand it while listening is poor, and my ability to speak it is laughable. OTOH I can read pretty much any computer language and am fluent in...um...a lot...I can't really recall.

      --
      All those moments will be lost in time, like tears in rain.
  11. Re:Balderdash by BlackHawk-666 · · Score: 2

    Languages take time and effort to learn. Try to remember, C++, although complex by the standards of most computer languages is ridiculously easy compared to learning French. If the programmers spent a proportional amount of time on the foreign language, I think they would have the same level of mastery.

    --
    All those moments will be lost in time, like tears in rain.
  12. And reading code isn't "coding" by raftpeople · · Score: 2

    For me, coding/design/problem solving seems to be mostly 3d abstract visual with objects being represented by some abstract entity and interactions that I can "see" (in quotes because I'm not sure that's what's really going on) and manipulate.

    Reading or writing code is a translation to/from the imagery which is the real "code". The imagery is the abstract representation of the solution and where the problem solving happens.

  13. Re:Balderdash by aristotle-dude · · Score: 2
    One of my colleagues in the past had a degree in divinity, and the one who hired my had a psychological degree. You appear to assume that a background in physics or mathematics would give a distinct advantage over others in programming in all fields. While I'm sure those skills are a basic necessity in developing new physics engines and possibly a new sorting, compression or encryption algorithm, many fields do not require a developer to "reinvent" the wheel and they can simply use existing proven technologies. This is often called building on the "shoulders of giants".

    I think that the fact that I am multilingual and have a firm grasp of "logic" is far more useful than any mathematics that I might have learned in school. I view programming as more of an "art" than a science. It is a form of expression and the programming languages are analogous to human languages used in writing stories and prose. One could say that methods of a class are very much like prose on a conceptual level and the class is analogous to a chapter in a book.

    --
    Jesus was a compassionate social conservative who called individuals to sin no more.
  14. same brain region != equivalent cognition by Immerman · · Score: 4, Interesting

    While it seems logical to me that there would be heavy overlap between the brain regions used for natural language and those for reading programming languages, it's important to remember that "using the same brain region" is *not* equivalent to "thinking in the same way". For example poetry and mathematics both activate many of the same brain regions, presumably because they both involve a lot of pattern recognition and abstract thought.

    For that matter, if I recall correctly the language centers of the brain are themselves mostly a subset of the vision centers of the brain, even when dealing with purely spoken language. Probably that pattern-recognition stuff showing up again

    --
    --- Most topics have many sides worth arguing, allow me to take one opposite you.
  15. Neuroscience doesn't lie? by abies · · Score: 2

    http://www.wired.com/wiredscie...

    I suppose that dead salmon should get credits for social science classes in such case...

  16. Re:Ha. Your description IS a branch of mathematics by Uecker · · Score: 2

    The Curry-Howard isomorphism is a way to relate programs to proofs and types to propositions. Control flow can be expressed in terms of call/cc and relates to Peirce's law in logic.

  17. Re:Balderdash by Bryan+Ischo · · Score: 2

    I am a programmer and have a degree in Math/Computer Science, but I always scored better on language related aptitude tests than math ... did significantly better on my SAT and ACT tests (in 1989! I'm sure they've changed alot since then!) in language related areas than I ever did in math. Luckily I still got into a good computer science school, got my degree, and have had a pretty good career in software development. I never realized that my skew towards language skill may actually have been a boon for my career choice instead of the disadvantage that I thought it was ...

  18. Re:Why? by Half-pint+HAL · · Score: 2

    English is universally derided among them for being the easiest to learn.

    English is easy to start learning, but very difficult to master. The first year of learning English is easy, whereas the first year of learning (eg) French is pretty difficult. But after that first year, you know the hard parts of French, and all that's left to learn is the easy stuff. English... well, the worst is yet to come.

    The grammar is pathetic. The rules are arbitrary but easily picked up.

    Rules that are truly arbitrary are never easy to pick up. Rules must maintain some internal logic.

    The problem with English is that its simple syntax and lack of inflectional complexity means that grammatical complexity is transferred to word bundles. The stuff of nightmares for the Spanish learner-of-English is the "phrasal verb". "pick up" may use the words "pick" and "up", but the verb "pick" means "choose", whereas there's no implied choice-of-thing in "pick up". When we "pick up a ladder", we "pick it up". When we "set up a ladder", we "set it up". But when we "go up a ladder" we "go up it". This is internally logical, but despite that, it still trips learners up, because what looks like the same pattern superficially is actually two different ones.

    The words all comes from Latin or Greek or Germanic originally.

    That doesn't make it easy. German's vocabulary almost all comes from Germanic. French's vocabulary almost all comes from Latin. Modern Greek's vocabulary almost all comes from Ancient Greek. Whereas English has a hodge-podge of the three plus French, and it's difficult to predict which words we use, and which we don't. Our "kings" are Germanic, and when they act "regal" they are Latin, whereas their "royal" virtues are French.

    The lack of clear shared roots in related nouns, adjectives and verbs makes the learning of English vocabulary a long and thankless task.

    --
    Got them moderator blues I blieve I walk out the do', With these mod-points I been gettin', I 'most never post no mo'