As part of eye movement research, Mike Hansen and Erik Kholk conducted a curious experiment. Using the Tobii TX300 eytreker with a frequency of 300 Hz, they compared the behavior of the eyes of experienced and novice programmers when reading the Python program code, the output of which was a matter of the task.
As a result of shooting data for the "newcomer" the following video was received.
')
Video "experienced" (Eric).
According to the records obtained , a number of conclusions were made. In particular, it was noticed that the professional's view turns all the actions of the program. Initially, the “experienced” reads the entire program, and only then begins the process of its execution. The program consisted of two function calls between , followed by a common call, and most of the time “experienced” was spent casting a glance between calls and function definitions.
In fact, an experienced programmer did a certain kind of compilation: first, all the functions are understood, then the action performed by the function is remembered in order to get its output faster. Interpretation of the first call took about 24 seconds, the second was swept away in 10.
It was also noted that the correct names help orient and scroll through the actions in the head faster. Reading the program, the “experienced” associated the action of the function with her name, having first verified that the equivalent in the head corresponds to the action of the function. When solving the problem, the equivalent was used, and not the function itself.
While the “experienced” task performance is influenced by the names, the “newbies” do not show significant differences in the duration of execution when the associability of variable names changes. It is clearly seen that, at around 1:30 am, the “newcomer” recognized the familiar algorithm, after which she collects attention on the necessary numbers, without being distracted by the passage of random lines, reaches common and leaves an extra comma.
The purpose of the study is to help the research community of psychology and programming, which lacks models of the processes occurring in the brain of a programmer. Mike wants to create a computational cognitive model of a programmer that will be able to “read” the code in the same way a living person would. Such a model could help analyze the code base, which would allow replacing or supplementing indicators such as the number of lines of code or cyclomatic complexity .
Mike Hansen is still recruiting volunteers who own Python and live in Bloomington, Illinois to participate in the experiment.