Computer Science and Engineering, Department of

 

Computer Science, Computer Engineering, and Bioinformatics: Dissertations, Theses, and Student Research

First Advisor

Robert Dyer

Committee Members

Bonita Sharif, Hamid Bagheri, Jason Hawkins

Date of this Version

8-2025

Document Type

Dissertation

Citation

A dissertation presented to the faculty of the Graduate College at the University of Nebraska in partial fulfilment of requirements for the degree of Doctor of Philosophy

Major: Computer Science

Under the supervision of Professor Robert Dyer

Lincoln, Nebraska, August 2025

Comments

Copyright 2025, Samuel W. Flint. Used by permission

Abstract

Optional type annotations are a popular feature of programming languages that allow developers to omit explicit type information in code while, in some cases, retaining many of the benefits of static typing, such as in-code documentation, improved detection of type errors, or enforcement of code properties. However, how developers use and understand optional type annotations is not clear. The focus of this dissertation is to understand the use and comprehension of optional type annotations.

Optional type annotations are examined through four lenses: first, by examining the evolution of usage in a statically typed programming language (Kotlin, the default language for Android), we find that locations tend to retain their annotation (or lack thereof) over time, and some locations such as initialized class fields and single-expression method return types receive type annotations more frequently than others.

Second, by examining the output of large language models (LLMs) for the presence of type annotations when generating code, we find differing behavior between languages, with Python being minimally annotated unless explicitly requested. But explicitly requesting types also leads to more syntax errors.

Third, by using eye tracking to better understand developer reference behavior (such as looking back at a line containing a declaration) with respect to type annotations, we find that developers did not engage in reference behavior more frequently in code with type annotations.

Finally, through direct intervention, asking developers why they made a particular change to a type annotation, we find the three most common reasons type annotations are modified (or added/removed) are due to an incorrect type causing an error, to improve their function as documentation, or to adhere to a formal convention.

Together, this confirms that developers view type annotations as documentation, especially in certain locations, even if they are rarely modified. However, how this information gets utilized by other developers or LLMs is unclear: we do not see evidence that developers refer to it during bug localization, and we see that requesting type annotations can cause downstream problems for popular tools such as LLMs.

Advisor: Robert Dyer

Share

COinS