Statically-annotated types have been shown to aid developers in a number of programming tasks, and this benefit holds true even when static type checking is not used. It is hypothesized that this is because developers use type annotations as in-code documentation. In this study, we aim to provide evidence that developers use type annotations as in-code documentation. Understanding this hypothesized use will help to understand how, and in what contexts, developers use type information; additionally, it may help to design better development tools and inform educational decisions. To provide this evidence, we conduct an eye tracking study with 26 undergraduate students to determine if they read type annotations during code comprehension and bug localization in the TypeScript language. We found that developers do not look directly at lines containing type annotations or type declarations more often when they are present, in either code summarization or bug localization tasks. The results have implications for tool builders to improve the availability of type information, the development community to build good standards for use of type annotations, and education to enforce deliberate teaching of reading patterns.
翻译:静态类型标注已被证明能在多种编程任务中辅助开发者,即使在不使用静态类型检查的情况下这种益处依然存在。假设这是因为开发者将类型标注视为代码内文档。本研究旨在提供证据证明开发者确实将类型标注作为代码内文档使用。理解这种假设性用途将有助于了解开发者如何以及在何种情境下使用类型信息;此外,这可能有助于设计更好的开发工具并为教育决策提供参考。为提供证据,我们对26名本科生进行了眼动追踪研究,以确定他们在理解TypeScript代码和定位缺陷时是否会阅读类型标注。研究发现,无论是在代码总结任务还是缺陷定位任务中,当存在类型标注或类型声明时,开发者并不会更频繁地直接注视包含这些内容的代码行。该结果对工具开发者改进类型信息的呈现方式、开发社区建立类型标注使用的良好规范、以及教育领域加强阅读模式的有意识教学都具有启示意义。