Scala with Explicit Nulls

Loading...
Thumbnail Image

Date

2019-12-20

Authors

Nieto Rodriguez, Abel

Advisor

Lhoták, Ondřej

Journal Title

Journal ISSN

Volume Title

Publisher

University of Waterloo

Abstract

The Scala programming language unifies the object-oriented and functional styles of programming. One common source of errors in Scala programs is null references. In this dissertation, I present a modification to the Scala type system that makes nullability explicit in the types. This allows us to turn runtime errors into compile-time errors. I have implemented this design for explicit nulls as a fork of the Dotty (Scala 3) compiler. I evaluate the design by migrating a number of Scala libraries to use explicit nulls. In the second part of the dissertation, I give a theoretical foundation for explicit nulls. I do this in two, independent ways. First, I give a denotational semantics for type nullification, a key part of the explicit nulls design. Separately, I present a core calculus for null interoperability that models how languages with explicit nulls (like Scala) interact with languages where null remains implicit (like Java). Using the concept of blame from gradual typing, I show that if a well-typed program fails with certain kinds of nullability errors, an implicitly-nullable subterm can always be blamed for the failure.

Description

Keywords

programming languages, type systems, scala, nullability, gradual typing, denotational semantics, compilers

LC Subject Headings

Citation