Even for Experts! What Makes Code Hard to Understand?
When I visited Indiana earlier this year, I got a chance to meet with Rob Goldstone who told me about these fascinating results that Michael Hansen describes in the blog post linked below — that adding two blank lines to a Python program (which has no change to execution) significantly changes how programmers understand the code. Are his participants getting confused, because spacing matters horizontally in Python but not vertically?
The other experiments that Michael describes below, like the one I’m quoting below, are also amazing. Michael isn’t dealing with students — most of his participants are programmers with 2-10 years worth of experience, and graduate degrees. How could they get this code so wrong, when the problem is the kind of thing we might give on a CS1 exam? Here’s one hypothesis: We really don’t know just how hard programming is, and both students and programmers understand it far less well than we expect.
Why did 50% of our participants get this program wrong? There is a strong expectation amongst programmers that you don’t include code that won’t be used. Elliot Soloway identified this and other maxims (or rules of discourse) in 1984. Like conversational norms, these unwritten rules can have a powerful influence on interpretation.