Much Ado About Nothing - Northeastern University

Much Ado About Nothing:

Putting Java's Null in its Place

A dissertation presented by

Richard Cobbe

to the College of Computer and Information Science

in partial fulfillment of the requirements for the degree of Doctor of Philosophy

in the field of

Computer Science

Northeastern University Boston, Massachusetts

December 1, 2008

Copyright 2008 Richard C. Cobbe All Rights Reserved

i

Abstract

Mainstream object-oriented languages include a null value that inhabits every object type and that pervades programs. It exists both because the language semantics requires it in certain places and because it is the most convenient representation for common patterns, such as for sentinel values indicating failure. Safety requires implementations of these languages to insert run-time checks throughout programs to determine whether object references are null at each field lookup and method call.

The ubiquity of null in object-oriented programs leads to severe engineering problems for programmers. First, the error messages issued by the run-time checks are typically not sufficiently informative to help the programmer find the source of the error. Second, the type systems in OO languages generally do not distinguish null from other values of (object) type, preventing the programmer from stating important invariants about the flow of null in the type system. Third, programmers' standard use of null as a sentinel does not unambiguously represent failures. To resolve or avoid these ambiguities, component authors must incorporate additional complexity into their interfaces, and this complexity can lead to subtle bugs.

In this dissertation, we propose two changes to Java that allow us to completely remove the null value. Doing so addresses the problems above and provides significant engineering benefits to the programmer. Further, we demonstrate the practical feasibility of our proposal with a migration path that allows programmers to shift large codebases from Java to our new language, one class at a time.

Acknowledgments

I am deeply grateful to many people for the support and assistance they have provided during while I have worked on my dissertation. Chief among them are the members of my committee, Professors Karl Lieberherr, Olin Shivers, both of Northeastern University, and Professor Robert Muller of Boston College. Without their support, suggestions, and insight I could never have completed this. My advisor, Matthias Felleisen, has repeatedly demonstrated his devotion to his students, spending long hours reading drafts, discussing the technical points in detail, always spurring us on to better and better performance, and supporting us in other ways too many to mention here.

Just as important to this dissertation and to my development as a graduate student are the members of the Programming Research Laboratory at Northeastern University. This large, vibrant group has been an ideal environment for the study of programming languages, and I cannot begin to list all of the things I have learned from my classmates and professors. I especially want to thank Professor Mitchell Wand, Ryan Culpepper, David Herman, and Theo Skotiniotis; our many discussions have helped me to refine and polish this work in ways I could not have done otherwise. Jesse Tov provided invaluable help in evaluating OOHaskell. Thanks also to Ryan Culpepper and Cormac Flanagan for suggesting my title and subtitle, respectively.

My employers at The MathWorks have very graciously allowed me the time and flexibility that I needed to finish this dissertation. I am also grateful that they have provided me with an opportunity to work on projects that involve ideas that, while perhaps not directly connected to this dissertation, are at least closely related.

Finally, I must also acknowledge my debt to many friends who provided personal support during my time in graduate school. They have spent far more time than I had a right to expect listening to me as I adapted to the academic research community and struggled to find my place in it. In addition to the classmates and professors above, I also owe a debt to many others: in no particular order, Robert Mack, Dean Lampros, Joe Teja, Terry Lewis, and of course the many members of the Back Bay Chorale and its Parish Committee. These people have provided support, empathy, fun, friendship, and most importantly an opportunity to reconnect with a part of myself I had long neglected.

iii

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download