Unexpected but informative: What fixation-related potentials tell us about the processing of confusing program code
Annabelle Bergum, Anna-Maria Maurer, Norman Peitek, Regine Bader, Axel Mecklinger, Vera Demberg, Janet Siegmund, Sven Apel
TL;DR
This study investigates how programmers process confusing code constructs (atoms of confusion) by recording fixation-related potentials (FRPs) during naturalistic code reading. Using a data-driven FRP approach, the authors compare confusing and clean code, finding a robust late frontal positivity starting around $390$–$660$ ms after first fixation on the critical region, along with slower comprehension and reduced accuracy for confusing snippets. The results suggest that the brain employs neurocognitive mechanisms akin to those in natural language processing to update the situation model in response to unexpected but plausible inputs, with implications for coding conventions, programming language design, and education. The work demonstrates the ecological validity of FRP methods in software engineering and paves the way for interdisciplinary collaboration between software engineering and psycholinguistics.
Abstract
As software pervades more and more areas of our professional and personal lives, there is an ever-increasing need to maintain software and for programmers to efficiently write and understand program code. In the first study of its kind, we analyze fixation-related potentials (FRPs) to explore the online processing of program code patterns that are confusing to programmers, but not to the computer (so-called atoms of confusion), and their underlying neurocognitive mechanisms in an ecologically valid setting. Relative to clean counterparts in program code without an atom of confusion, confusing code elicits a late frontal positivity of about 400 to 700 ms after first looking at the atom of confusion. This frontal positivity resembles an event-related potential (ERP) component found during natural language processing that is elicited by unexpected but plausible words in sentence context. Thus, we suggest that the brain engages similar neurocognitive mechanisms in response to unexpected and informative inputs in program code and in natural language. In both domains, these inputs update a comprehender's situation model, which is essential for information extraction from a quickly unfolding input. Our results have far-reaching implications for programming and pave the way for interdisciplinary collaborations between software engineering and psycholinguistics.
