Summary: An interdisciplinary neuro-software engineering study unmasked the exact millisecond-by-millisecond brain activity that occurs when computer programmers process confusing source code. The investigation combined electroencephalography (EEG) with high-speed eye-tracking to capture fixation-related potentials (FRPs), neural signals recorded precisely when a developer’s eyes focus on a specific line of code.
By exposing 24 programmers to “atoms of confusion” (semantically ambiguous code blocks), an international research team discovered that processing confusing code triggers a specific neurological wave called late frontal positivity. This exact signature matches the brainโs response to unexpected linguistic twists in natural language, proving that programmers subconsciously treat code comprehension like real-time conversational correction.
Key Facts
- The FRP Fixation Breakthrough: Traditional EEG tracking struggles with movement artifacts caused by natural eye scanning. To bypass this, the team synchronized eye-tracking with EEG to measure fixation-related potentials (FRPs). This allowed scientists to capture stable brain activity at the exact millisecond the eyes stopped moving to focus on a targeted line of code.
- Isolating Atoms of Confusion: The experimental architecture targeted “atoms of confusion”โfrequent, highly compact source code snippets that a computer executes without error but completely trip up human programmers, causing the human and the machine to arrive at totally different logical conclusions.
- The 1,700-Trial Dataset: Computer scientist Anna-Maria Maurer built a highly sophisticated testing layout consisting of three thematic blocks. Over 1,700 distinct trials across 24 professional programmers were recorded, with eye-tracking data and neural responses synchronized down to the individual millisecond.
- The “Jacket” Linguistic Parallel: When developers hit a confusing patch of code, their brains generated a distinct late frontal positivity wave. Computational linguist Dr. Vera Demberg noted this matches psycholinguistic experiments where a reader encounters an unexpected turn of phrase (e.g., “Theo wants to chop wood, so he goes to fetch a jacket” instead of “an axe”).
- Split-Second Mental Re-Architecting: The late frontal positivity signature indicates that the programmer’s brain is rapidly adapting in a fraction of a secondโcross-referencing the unexpected code against long-term memory structures and instantly rewriting their internal mental simulation of how the software functions.
- How Code Processing Beats Reading: While programming shares neural networks with natural language processing, eye-tracking confirmed that programmers do not read linearly. Instead, they scan massive contextual structures, processing multiple lines simultaneously and treating complex multi-layered blocks as single, integrated semantic units.
- Engineering Human-Centric IDEs: Because professional software developers spend 70% to 80% of their working hours simply reading and trying to comprehend code, mapping these thought processes allows tech firms to build smarter Integrated Development Environments (IDEs) that flag cognitive traps before an error is ever compiled.
Source: Saarland University
โSoftware solutions are embedded in our everyday lives, and when they are faulty the consequences can be serious. So, itโs essential that programmers understand their code and donโt overlook errors or introduce new ones when adding further functionality,โ says Sven Apel, professor of computer science at Saarland University.
Apel and his colleagues want to understand more precisely what happens in a software developerโs brain when writing and analysing code. Three years ago, he brought Axel Mecklinger, professor of experimental neuropsychology at Saarland University, into the project.
Together, they combined electroencephalography (EEG) with eye-tracking data to record signals known technically as fixation-related potentials (FRPs).
โThe advantage of the FRP approach is that it allows us to record brain activity at the exact moment when the eyes stop moving and focus on a specific target,โ explains Axel Mecklinger.
The research team set out to discover how software developers react when they encounter confusing snippets of code known as โatoms of confusionโ. These small portions of code occur quite frequently in source code and cause a person and a machine to come to different conclusions regarding the output.
While the computer can interpret and execute them unambiguously, they are not intuitively clear to the programmer, which means the programmer may misunderstand how the program works. Anna-Maria Maurer, a doctoral research student in computer science working with Professor Apel, incorporated this type of confusing code into the experimental design. She recruited 24 programmers as participants, whose brain activity and eye movements were recorded over around 1,700 trials.
To analyse the measurement data, the team drew on methods and expertise from psycholinguistics, although the methodology could not simply be transferred to the study of software programming. Earlier studies had already shown that programming activates brain regions similar to those involved in natural language processing, but the way programmers approach code differs from the way people process language.
โWhen we want to understand how the brain processes particular conversational situations, we ask participants to read short text passages and compare this with the EEG and eye-tracking data. But when reading code, programmers process larger contextual blocks, scanning several lines at once and perceiving complex structures as single units,โ explains Vera Demberg, professor of computational linguistics, who with her team was involved in analysing the data.
To take this added complexity into account, the experimental set-up and design had to be correspondingly more sophisticated. The code snippets were presented to the participants in three thematic blocks, with each block comprising 24 individual trials, while EEG and eye-movement data were recorded and synchronized to the millisecond.
When the team compared EEG signals from earlier natural language studies with the new findings from their software programming study, they identified a striking pattern known in neuropsychology as late frontal positivity.
โWhen the programmers encountered confusing snippets of code, they showed brain activity similar to that seen in linguistic experiments where participants read sentences containing unexpected turns of phrase. The brain then adapts in a split second, checking the information against long-term memory and updating the mental representation of the new situation in order to make sense of it,โ explains Vera Demberg.
To illustrate whatโs happening, Axel Mecklinger cites the sentence โTheo wants to chop wood, so he goes to fetch a jacket.โ as an example of just such an unexpected turn in conversation. Upon encountering the words โgoes to fetchโ the reader would normally expect this to be followed by โan axeโ. A jacket, by contrast, is certainly plausible, but still comes as a surprise in this context.
โIn our EEG experiments on language processing, unexpected words such as โjacketโ generate a late frontal positivity โ a signal that bears a very strong resemblance to the EEG response elicited by confusing code snippets,โ says neuropsychologist Axel Mecklinger.
โBecause programmers spend 70 to 80 percent of their time trying to understand code, itโs important that we understand how their thought processes work. The insights we gain can help us develop better tools that either eliminate coding pitfalls from the outset or make them easier to detect.
These findings could also inform how we go about training software developers,โ explains computer scientist Sven Apel. In future studies, he hopes to investigate whether programmers show different patterns of brain activity when the confusing snippets of code are actually faulty, or when they are shown lines of code that do not require spontaneous rethinking, i.e. spontaneous revision of the programmerโs mental representation of the situation.
The study, published in the prestigious journalย Scientific Reports, involved Annabelle Bergum, Anna-Maria Maurer, Norman Peitek, Regine Bader, Axel Mecklinger, Janet Siegmund, Vera Demberg and Sven Apel. All of the authors are researchers at Saarland University, with the exception of Janet Siegmund, who is professor of software engineering at Chemnitz University of Technology.
The study is linked to several major research programmes at Saarland University and received funding from them. These include the Transregional Collaborative Research Centre 248, โFoundations of Perspicuous Software Systemsโ (co-spokesperson: Professor Holger Hermanns), the ERC Advanced Grant โBrains on Codeโ (PI: Professor Sven Apel), and the Collaborative Research Centre 1102 on Information Density and Linguistic Encoding (spokesperson: Professor Elke Teich), in which Vera Demberg and Axel Mecklinger are involved.
Key Questions Answered:
A: It is a tiny snippet of source code that is perfectly clear to a computer but highly confusing to a human programmer. The machine executes the instruction exactly as written without throwing an error, but because the logic is un-intuitive, the human developer misinterprets what the code is actually doing, leading them to predict a completely incorrect output.
A: It reacts exactly like a person reading a sentence with a surprising twist. Saarland University researchers discovered that the brain produces a wave called late frontal positivity. In a split second, the brain stops its standard processing, cross-references long-term memory, and rapidly re-architects its mental model of the situation to make sense of the unexpected code.
A: Because programmers spend up to 80% of their time simply reading and trying to comprehend existing code rather than writing new lines. By using eye-tracking and EEG to map out what makes code hard to understand at a neurological level, scientists can design next-generation developer tools and training programs that prevent human errors from being introduced in the first place.
Editorial Notes:
- This article was edited by a Neuroscience News editor.
- Journal paper reviewed in full.
- Additional context added by our staff.
About this linguistics and neuroscience research news
Author:ย Thorsten Mohr
Source:ย Saarland University
Contact:ย Thorsten Mohr โ Saarland University
Image:ย The image is credited to 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 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.

