‘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.
Scientific Reports
Experimental study
People
Fixation-related potentials reveal that confusing program code elicits a late frontal positivity
1-Jun-2026