一句话:眼动实验表明,Copilot 生成代码可读性接近人类,但程序员对其视觉关注显著更少。
论文关注大型语言模型用于代码生成后,实践中的代码可读性与视觉检查问题。作者以 GitHub Copilot 为对象,开展 n=21 的人体实验,将模型生成代码与完全由人类程序员(含结对编程)编写的代码进行对比。方法结合静态代码分析与人工标注评估可读性,并用眼动追踪测量程序员阅读代码时的视觉注意力分配。结果显示,模型生成代码在复杂度和可读性上与人类结对程序员编写的代码相当;但眼动数据在统计显著水平上表明,程序员对模型生成代码投入的视觉注意力更少。作者据此指出,在自动化偏见和自满风险下,阅读代码比以往更重要。
Background: Recent advancements in large language models have motivated the practical use of such models in code generation and program synthesis. However, little is known about the effects of such tools on code readability and visual attention in practice. Objective: In this paper, we focus on GitHub Copilot to address the issues of readability and visual inspection of model generated code. Readability and low complexity are vital aspects of good source code, and visual inspection of generated code is important in light of automation bias. Method: Through a human experiment (n=21) we compare model generated code to code written completely by human programmers. We use a combination of static code analysis and human annotators to assess code readability, and we use eye tracking to assess the visual inspection of code. Results: Our results suggest that model generated code is comparable in complexity and readability to code written by human pair programmers. At the same time, eye tracking data suggests, to a statistically significant level, that programmers direct less visual attention to model generated code. Conclusion: Our findings highlight that reading code is more important than ever, and programmers should beware of complacency and automation bias with model generated code.