An experiment on the cognitive complexity of code

Hansen, M. E., Lumsdaine, A., & Goldstone, R. L. (2013).  An experiment on the cognitive complexity of code.  Proceedings of the Thirty-Fifth Annual Conference of the Cognitive Science Society. Berlin, Germany: Cognitive Science Society.

What simple factors impact the cognitive complexity of code? We present an experiment in which participants predict the output of ten small Python programs. Even with such simple programs, we find a complex relationship between code, expertise, and correctness. We use subtle differences between program versions to demonstrate that small notational changes can have profound effects on comprehension. We catalog common errors for each program, and perform an in-depth data analysis to uncover effects on response correctness and speed.

Download PDF version of this paper