Skip to main content
eScholarship
Open Access Publications from the University of California

Does Surprisal Predict Code Comprehension Difficulty?

Creative Commons 'BY' version 4.0 license
Abstract

Recognition of the similarities between programming and nat-ural languages has led to a boom in the adoption of languagemodeling techniques in tools that assist developers. However,language model surprisal, which guides the training and eval-uation in many of these methods, has not been validated asa measure of cognitive difficulty for programming languagecomprehension as it has for natural language. We perform acontrolled experiment to evaluate human comprehension onfragments of source code that are meaning-equivalent but withdifferent surprisal. We find that more surprising versions ofcode take humans longer to finish answering correctly. Wealso provide practical guidelines to design future studies forcode comprehension and surprisal.

Main Content
For improved accessibility of PDF content, download the file to your device.
Current View