What is it about?
Software teams often rely on code metrics that estimate “complexity”, but these numbers do not capture the human side of reading and understanding code. In this paper, we explore whether a person’s eye movements while reading code can reveal when code is understood and when it feels difficult. This work moves beyond “code-only” complexity measures and directly models how people actually read code. Instead of inferring difficulty from syntax metrics alone, we combine the source code with eye movement patterns captured during real comprehension tasks, and show that this joint view improves prediction of both understanding (correctness) and perceived difficulty. That combination is still rare in software engineering research and it helps bridge a long-standing gap between automated code analysis and human cognition. We ran a lab study where 27 participants solved 16 short code comprehension tasks while an eye tracker recorded exactly where they looked and for how long. We then trained an AI model that learns from both the source code and the reader’s gaze patterns to predict two outcomes: whether the person will answer correctly and whether they will rate the code as hard or easy. Our results show that combining code with gaze data predicts comprehension and perceived difficulty more accurately than prior approaches, and it also performs better than models that use only code or only gaze. This matters because developers increasingly work in environments where speed is high and attention is fragmented (for example, code review at scale and AI-assisted coding). In that context, being able to detect “this code is likely confusing for humans” is valuable. The approach points toward tools that can flag confusing code early, help teams prioritize refactoring and review effort, support training and onboarding by identifying where readers struggle, and provide more human-grounded evidence about readability than traditional complexity scores.
Featured Image
Photo by v2osk on Unsplash
Why is it important?
Instead of relying on complexity metrics or features extracted from the source code alone, this work uses eye tracking to capture how people actually move through a program while trying to understand it, and combines that signal with the code itself in a single predictive model. This makes it possible to estimate both whether someone will understand the code and whether they will experience it as difficult, using evidence from real reading behavior.
Perspectives
What I personally found most interesting about this paper was the chance to turn something that is usually invisible, the human process of understanding code, into a signal a model can learn from. Code comprehensibility is often treated as a property of the program, but in practice, it is strongly influenced by human perception. Building a model that connects the code itself with how people visually navigate it felt like a meaningful step toward representing comprehension in a more human grounded way – it was satisfying to see that the model benefits from that combination.
Tarek Alakmeh
Universitat Zurich
Read the Original
This page is a summary of: Predicting Code Comprehension: A Novel Approach to Align Human Gaze with Code using Deep Neural Networks, Proceedings of the ACM on Software Engineering, July 2024, ACM (Association for Computing Machinery),
DOI: 10.1145/3660795.
You can read the full text:
Resources
Contributors
The following have contributed to this page







