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 | |||
15:30 30mTalk | Just-in-Time Static Type Checking for Dynamic Languages Research Papers Brianna M. Ren University of Maryland, College Park, Jeffrey S. Foster University of Maryland, College Park Media Attached | ||
16:00 30mTalk | Types from data: Making structured data first-class citizens in F# Research Papers Tomas Petricek University of Cambridge, UK, Don Syme Microsoft, Gustavo Guerra Microsoft Corporation, London Pre-print Media Attached | ||
16:30 30mTalk | Automatically Learning Shape Specifications Research Papers He Zhu Purdue University, Gustavo Petri LIAFA, Université Paris Diderot, Suresh Jagannathan Purdue University Media Attached |