Summary: An interdisciplinary study combining neuroscience and software engineering has mapped the millisecond-by-millisecond brain activity that occurs when programmers read confusing source code. Using electroencephalography (EEG) synchronized with high-speed eye-tracking, researchers recorded fixation-related potentials (FRPs) — brain signals tied precisely to the moment a developer’s gaze fixes on a particular line of code.
In experiments with 24 professional programmers, the team exposed participants to so-called “atoms of confusion” — concise code snippets that are syntactically valid for computers but are likely to mislead human readers. The study found that encountering these confusing code fragments consistently triggered a distinct neural response known as late frontal positivity. This neural signature mirrors the brain activity observed when people read unexpected or surprising words in natural language, indicating that code comprehension engages processes similar to real-time language repair and updating.
Key Facts
- Measuring fixation-related potentials (FRPs): By synchronizing eye-tracking with EEG, the researchers overcame motion-related noise that typically limits EEG in natural viewing. This approach isolates brain responses at the exact millisecond a reader’s eyes stop moving and fixate on a target line of code.
- Targeting atoms of confusion: The experiments focused on compact code constructs that execute correctly but are prone to human misinterpretation. These atoms of confusion frequently appear in real-world source code and can cause a developer’s mental model to diverge from the program’s actual behavior.
- A large, finely timed dataset: The study recorded roughly 1,700 trials across 24 programmers. Eye movements and EEG were synchronized at millisecond resolution, enabling precise temporal mapping of how confusion unfolds in the brain.
- Late frontal positivity as a shared signal: The confusing code snippets elicited a late frontal positivity approximately 400–700 ms after fixation. This waveform closely resembles an ERP component observed when readers encounter unexpected but plausible words in sentences, suggesting shared neurocognitive mechanisms between code and language processing.
- Rapid mental re-architecting: The late frontal positivity reflects a swift cognitive update: the brain pauses its default processing, checks the surprising input against long-term memory, and revises the internal model of the program’s behavior within fractions of a second.
- Nonlinear reading of code: Eye-tracking showed that programmers rarely read code linearly. Instead, they scan broader contextual structures, often processing several lines at once and treating nested or multi-line constructs as single meaningful units.
- Implications for developer tools: Since professional developers spend an estimated 70–80% of their time reading and understanding code, mapping these cognitive patterns can guide the design of human-centric integrated development environments (IDEs) that flag likely cognitive traps before errors arise.
Source: Saarland University
“Software solutions are embedded in our everyday lives, and when they are faulty the consequences can be serious. It is essential that programmers understand their code and don’t overlook errors or introduce new ones when adding functionality,” says Sven Apel, professor of computer science at Saarland University.
Apel and his colleagues set out to investigate the neural processes involved when developers read and analyze code. They partnered with Axel Mecklinger, professor of experimental neuropsychology, to combine EEG with eye-tracking and record fixation-related potentials (FRPs). According to Mecklinger, the FRP method captures brain activity precisely at the moment the eyes stop moving and the reader focuses on a code fragment.
Doctoral researcher Anna-Maria Maurer designed the experimental materials that embedded atoms of confusion into code examples and recruited 24 professional programmers. The experiment’s structure included three thematic blocks and produced a detailed dataset of eye movement and EEG responses across roughly 1,700 trials.
To interpret the EEG data, the team drew on psycholinguistic methods while adapting them to the unique nature of code comprehension. Computational linguist Vera Demberg explains that although programming and natural language activate overlapping brain regions, programmers approach code differently: they build situation models from larger contextual units rather than processing code in a strictly linear, word-by-word fashion.
When the researchers compared their EEG results to language studies, the late frontal positivity stood out. This signal typically appears when readers encounter unexpected but plausible words—an example used by the team is the sentence “Theo wants to chop wood, so he goes to fetch a jacket,” where “jacket” is surprising though conceivable. The same neurophysiological pattern emerges when developers encounter an atom of confusion, indicating an immediate update to the mental model of the program.
Apel emphasizes the practical value: understanding these cognitive processes can inform the creation of IDE features and training methods that reduce misunderstanding and prevent errors. Future research planned by the team will examine whether brain responses differ when confusing snippets are actual bugs versus intentionally misleading but correct code, and how training or tool support might change those neural patterns.
The study appears in the journal Scientific Reports and lists the authors Annabelle Bergum, Anna-Maria Maurer, Norman Peitek, Regine Bader, Axel Mecklinger, Vera Demberg, Janet Siegmund and Sven Apel. Most authors are affiliated with Saarland University; Janet Siegmund is professor of software engineering at Chemnitz University of Technology. The research received funding from multiple programs at Saarland University, including initiatives on software foundations, the ERC Advanced Grant “Brains on Code,” and collaborative research on information density and linguistic encoding.
Key Questions Answered:
A: An atom of confusion is a compact snippet of code that the computer executes deterministically but that is likely to mislead a human reader. Because its logic is unintuitive, developers may construct an incorrect mental model and predict the wrong outcome despite the code being valid.
A: The brain produces a late frontal positivity similar to the response triggered by unexpected but plausible words in natural language. Within a few hundred milliseconds the brain halts routine processing, checks the surprise against long-term memory, and updates the internal representation of the situation to restore coherence.
A: Because comprehension, not just writing, dominates programmers’ time. By revealing the neurocognitive triggers of misunderstanding, researchers can design developer tools and training that proactively reduce cognitive friction and prevent human errors from being introduced.
Editorial Notes:
- This article was edited by a Neuroscience News editor.
- The journal paper was reviewed in full.
- Additional context was added by staff.
About this linguistics and neuroscience research news
Author: Thorsten Mohr
Source: Saarland University
Contact: Thorsten Mohr – Saarland University
Image: Image credit: Neuroscience News
Original Research: Open access. “Fixation-related potentials reveal that confusing program code elicits a late frontal positivity” by Annabelle Bergum, Anna-Maria Maurer, Norman Peitek, Regine Bader, Axel Mecklinger, Vera Demberg, Janet Siegmund & Sven Apel. Scientific Reports. DOI: 10.1038/s41598-026-50946-9
Abstract
Fixation-related potentials reveal that confusing program code elicits a late frontal positivity
As software becomes increasingly central to work and daily life, maintaining and understanding program code grows ever more important. This study is the first to analyze fixation-related potentials (FRPs) during the real-time processing of program code patterns that confuse humans but not machines — the so-called atoms of confusion — within an ecologically valid experimental design.
Compared with clear code variants, confusing snippets prompted a late frontal positivity roughly 400–700 ms after first fixation. This ERP component resembles a response seen in natural language when readers encounter unexpected yet plausible words. The similarity suggests that, in both domains, the brain uses related neurocognitive mechanisms to update a comprehender’s situation model in response to surprising but informative inputs. These findings have practical implications for software engineering and promote interdisciplinary collaboration between programming research and psycholinguistics.