Psychology could inform Programming Language Syntax

Last weekend I attended a fascinating lecture by Rob Goldstone that reviewed much work that he has done over the course of a few decades. His talk was part of a workshop on Perceptual Learning and Expertise, co-organized by my colleague at Bryn Mawr College, Adrienne Prettyman:

Screenshot from 2017-02-28 08-43-18

Screenshot from 2017-02-28 08-43-31

One bit of research that Professor Goldstone described was the effect of spacing on interpreting mathematical equations. You can read a couple of research papers on the topic here:

  1. How Space Guides Interpretation of a Novel Mathematical System
  2. The Alignment of Ordering and Space in Arithmetic Computation

Basically, the findings show that spacing between symbols and numbers in a mathematical equation effect how people interpret the equation. So:

5 + 6*7

is interpreted correctly (i.e., perform the multiplication before the addition). However:

5+6 * 7

is interpreted incorrectly.

This suggests (at least to me) that programming languages could help prevent these kinds of errors by making such spacing as compile-time errors. Thus, if one tried to compile the second example above, you’d get an error. Python is already sensitive to indentation spacing, so paying attention to spacing does have some precedence. Programming languages could also require parentheses so that humans don’t have to apply their own PEMDAS, another source of mistakes.