TY - JOUR
T1 - An Empirical Study on Type Annotations
T2 - Accuracy, Speed, and Suggestion Effectiveness
AU - Ore, John Paul
AU - Detweiler, Carrick
AU - Elbaum, Sebastian
N1 - Funding Information:
This work is supported in part by NSF awards IIS-1638099, CCF-1718040, CCF-1853374, and CCF-1909414, and by USDA-NIFA 2017-67021-25924. Authors’ addresses: J.-P. Ore, North Carolina State University, 890 Oval Drive, Raleigh, NC, 27695; email: [email protected]; C. Detweiler, University of Nebraska–Lincoln, 256 Avery Hall, Lincoln, NE, 68588; email: [email protected]; S. Elbaum, University of Virginia, Rice 423, PO Box 400740, Charlottesville, VA, 22904; email: [email protected]. Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]. © 2021 Association for Computing Machinery. 1049-331X/2021/02-ART20 $15.00 https://doi.org/10.1145/3439775
Publisher Copyright:
© 2021 ACM.
PY - 2021/3
Y1 - 2021/3
N2 - Type annotations connect variables to domain-specific types. They enable the power of type checking and can detect faults early. In practice, type annotations have a reputation of being burdensome to developers. We lack, however, an empirical understanding of how and why they are burdensome. Hence, we seek to measure the baseline accuracy and speed for developers making type annotations to previously unseen code. We also study the impact of one or more type suggestions. We conduct an empirical study of 97 developers using 20 randomly selected code artifacts from the robotics domain containing physical unit types. We find that subjects select the correct physical type with just 51% accuracy, and a single correct annotation takes about 2 minutes on average. Showing subjects a single suggestion has a strong and significant impact on accuracy both when correct and incorrect, while showing three suggestions retains the significant benefits without the negative effects. We also find that suggestions do not come with a time penalty. We require subjects to explain their annotation choices, and we qualitatively analyze their explanations. We find that identifier names and reasoning about code operations are the primary clues for selecting a type. We also examine two state-of-the-art automated type annotation systems and find opportunities for their improvement.
AB - Type annotations connect variables to domain-specific types. They enable the power of type checking and can detect faults early. In practice, type annotations have a reputation of being burdensome to developers. We lack, however, an empirical understanding of how and why they are burdensome. Hence, we seek to measure the baseline accuracy and speed for developers making type annotations to previously unseen code. We also study the impact of one or more type suggestions. We conduct an empirical study of 97 developers using 20 randomly selected code artifacts from the robotics domain containing physical unit types. We find that subjects select the correct physical type with just 51% accuracy, and a single correct annotation takes about 2 minutes on average. Showing subjects a single suggestion has a strong and significant impact on accuracy both when correct and incorrect, while showing three suggestions retains the significant benefits without the negative effects. We also find that suggestions do not come with a time penalty. We require subjects to explain their annotation choices, and we qualitatively analyze their explanations. We find that identifier names and reasoning about code operations are the primary clues for selecting a type. We also examine two state-of-the-art automated type annotation systems and find opportunities for their improvement.
KW - Type checking
KW - annotations
KW - automated static analysis
KW - dimensional analysis
KW - physical units
KW - program analysis
KW - robotic systems
KW - software reliability
UR - http://www.scopus.com/inward/record.url?scp=85102884879&partnerID=8YFLogxK
UR - http://www.scopus.com/inward/citedby.url?scp=85102884879&partnerID=8YFLogxK
U2 - 10.1145/3439775
DO - 10.1145/3439775
M3 - Article
AN - SCOPUS:85102884879
SN - 1049-331X
VL - 30
JO - ACM Transactions on Software Engineering and Methodology
JF - ACM Transactions on Software Engineering and Methodology
IS - 2
M1 - 20
ER -