Why Is Code Hard to Understand?

Anyone who has tried to look at somebody else’s computer code — especially in the likely event that it hasn’t been well-commented — knows how hard it is to figure out what’s going on. (With sometimes dramatic consequences.) There are probably numerous reasons why, having to do with the difference between heuristic human reasoning and the starkly literal nature of computer instructions. Here’s a short paper that highlights one reason in particular: people tend to misunderstand code when it seems like it should be doing one thing, while it’s actually doing something else. (Via Simon DeDeo.)

What Makes Code Hard to Understand?
Michael Hansen, Robert L. Goldstone, Andrew Lumsdaine

What factors impact the comprehensibility of code? Previous research suggests that expectation-congruent programs should take less time to understand and be less prone to errors. We present an experiment in which participants with programming experience predict the exact output of ten small Python programs. We use subtle differences between program versions to demonstrate that seemingly insignificant notational changes can have profound effects on correctness and response times. Our results show that experience increases performance in most cases, but may hurt performance significantly when underlying assumptions about related code statements are violated.

As someone who is jumping back into programming myself after a lengthy hiatus, this stuff is very interesting. I wonder how far we are away from natural-language programming, where we can just tell the computer what we want in English and it will reliably do it. (Guess: pretty far, but not that far.)

27 Comments

27 thoughts on “Why Is Code Hard to Understand?”

  1. lasermazer@hotmail.com

    “It’s not about pretending to be human, it’s about a male human pretending to be a female human and thus requires that computers be able empathize with our sexuality. ”

    I’ve seen this revisionist claim made before (by Bruce Sterling), but I don’t buy it, I think this is trying too hard to find psychological insights in a technical paper. If you read the original paper, Turing first presents a scenario where you have two people “a man (A), a woman (B)”, both trying to convince an interrogator (C) that they are woman. It seems to me that this example is just brought up to illustrate the idea of someone trying to convince an interrogator that they are something they are not, in a conventional scenario involving two humans (and gender is one of the more obvious ways in which humans can differ). Turing then says:

    We now ask the question, “What will happen when a machine takes the part of A in this game?” Will the interrogator decide wrongly as often when the game is played like this as he does when the game is played between a man and a woman?

    I feel fairly certain that Turing was just making an analogy to the original imitation game, in effect saying “what if the same sort of game was played, except in this case instead of A being a man falsely pretending to be a woman, A is a machine falsely pretending to be a human?” (aren’t we all familiar with the looseness of how analogical phrases like “now imagine the same thing, except…” are used in everyday speech?) I don’t think the intention was that it was meant to be exactly the same game, including the fact that the machine was trying to convince the interrogator it was a woman. Just look at the questions Turing imagines asking A, which have nothing to do with gender and instead have to do with tasks we conventionally imagine humans being better at than machines or vice versa, like writing sonnets and quickly figuring out winning chess moves. Likewise notice where Turing talks about covering the machine with realistic artificial skin, and says even supposing this invention available we should feel there was little point in trying to make a “thinking machine” more human by dressing it up in such artificial flesh–he says “more human” (indicating that the machine is trying to trick the interrogator into thinking it’s a human), not “more like a woman”. So, I think all the contextual clues suggest that the standard understanding of the “Turing test” is the correct one.

  2. All been done. And in a real great way too.
    Development halted a while for various reasons. After going Open Source there is a lot of movement again.

    So forget about your braces {}, and if you are interested in the language I am talking about, take a look at http://www.rebol.com or go direct to http://www.rebol.com/docs/expert-intro.html

    There is a lot more and a lot of chances for if you want to dive in and contribute to the open source world.

    Regards,

    Arnold

Comments are closed.

Scroll to Top