Just-in-Time Static Type Checking for Dynamic Languages
Dynamic languages have many compelling benefits, but the lack of static types means subtle errors can remain latent in code for a long time. While many researchers have developed various systems to bring some of the benefits of static types to dynamic languages, prior approaches have trouble dealing with metaprogramming, which generates code as the program executes. For example, Ruby on Rails is a powerful framework that relies heavily on metaprogramming.
In this paper, we propose Hummingbird, a new system that can type check Ruby code even in the presence of metaprogramming. In Hummingbird, method type signatures are gathered dynamically at run-time, as those methods are created. When a method is called, Hummingbird statically type checks the method body against current type signatures. Thus, Hummingbird provides thorough static checks on a per-method basis, while also allowing arbitrarily complex metaprogramming. For performance, Hummingbird memoizes the static type checking pass, invalidating cached checks only if necessary. We formalize Hummingbird using a core, Ruby-like language and prove it sound. We also implemented Hummingbird and applied it to six apps, including three that use Rails. We found that all apps typecheck successfully using Hummingbird. By applying Hummingbird to earlier versions of one app, we also found several type errors that were introduced and then fixed. Finally, we found that Hummingbird’s performance overhead is reasonable.
Thu 16 JunDisplayed time zone: Tijuana, Baja California change
15:30 - 17:00
Types IIResearch Papers at Grand Ballroom San Rafael
Chair(s): Jean Yang Carnegie Mellon University
|Just-in-Time Static Type Checking for Dynamic Languages|
Brianna M. Ren University of Maryland, College Park, Jeffrey S. Foster University of Maryland, College ParkMedia Attached
|Types from data: Making structured data first-class citizens in F#|
Tomas Petricek University of Cambridge, UK, Don Syme Microsoft, Gustavo Guerra Microsoft Corporation, LondonPre-print Media Attached
|Automatically Learning Shape Specifications|
He Zhu Purdue University, Gustavo Petri LIAFA, Université Paris Diderot, Suresh Jagannathan Purdue UniversityMedia Attached