
How do we read the code
As part of eye movement research, Mike Hansen and Eric Hulk conducted an interesting experiment. Using the Tobii TX300 IT tracker with a frequency of 300 Hz, they compared the eye behavior of experienced and novice programmers when reading Python program code, the output of which was a matter of the task.
As a result of shooting data for the "beginner", the following video was received.
Video recording of the “experienced” (Eric).
Based on the obtained records, the researchers made a number of conclusions. In particular, it was noticed how the look of a professional cranks out all the actions of the program. First, the “experienced” reads the entire program, and only then begins the process of its implementation. The program consisted of two function calls
In fact, an experienced programmer conducted a certain kind of compilation: first, an understanding of all the functions is carried out, then the action performed by the function is remembered in order to get its output faster. The interpretation of the first call took about 24 seconds, the second was estimated to be 10.
It was also noticed that the correct names help to orient and scroll through the actions in the head faster. Reading the program, the “experienced” associated function with its name, after making sure 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 names of the "experienced" ones influence the speed of the task execution, the "newbies" do not show significant differences in the duration of the execution when the associativity of variable names changes. It can be clearly seen that at about 1:30 the “beginner” recognized the algorithm familiar to her, after which she collects attention on the necessary numbers, without being distracted by the passage of random lines, comes to
The purpose of the study is to help the research community of psychology and programming, which lacks models of processes occurring in the brain of a programmer. Mike wants to create a computational cognitive model for a programmer who will be able to "read" the code in the same way a living person would. Such a model could help to analyze the code base, which would replace or supplement 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.
As a result of shooting data for the "beginner", the following video was received.
Video recording of the “experienced” (Eric).
Based on the obtained records, the researchers made a number of conclusions. In particular, it was noticed how the look of a professional cranks out all the actions of the program. First, the “experienced” reads the entire program, and only then begins the process of its implementation. The program consisted of two function calls
between
, followed by a call common
, and the "experienced" spent most of the time casting a glance between calls and function definitions. In fact, an experienced programmer conducted a certain kind of compilation: first, an understanding of all the functions is carried out, then the action performed by the function is remembered in order to get its output faster. The interpretation of the first call took about 24 seconds, the second was estimated to be 10.
It was also noticed that the correct names help to orient and scroll through the actions in the head faster. Reading the program, the “experienced” associated function with its name, after making sure 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 names of the "experienced" ones influence the speed of the task execution, the "newbies" do not show significant differences in the duration of the execution when the associativity of variable names changes. It can be clearly seen that at about 1:30 the “beginner” recognized the algorithm familiar to her, after which she collects attention on the necessary numbers, without being distracted by the passage of random lines, comes to
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 processes occurring in the brain of a programmer. Mike wants to create a computational cognitive model for a programmer who will be able to "read" the code in the same way a living person would. Such a model could help to analyze the code base, which would replace or supplement 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.