Combining Static and Dynamic Typing in Ruby
Many popular scripting languages are dynamically typed. Dynamic typing provides many benefits, but it comes at a price: Programming mistakes that would easily be caught by static typing remain latent until run time, when they can be hard to track down and expensive to fix. In this talk, we will discuss Diamondback Ruby (DRuby), a research project that blends static and dynamic typing for Ruby. Our aim is to add a typing discipline that is simple for programmers to use, flexible enough to handle common idioms, that provides programmers with additional checking where they want it, and reverts to run-time checks where necessary. DRuby includes the Ruby Intermediate Language, a parser and front-end for Ruby; a static type language that is similar to the typing notation in the informal documentation for Ruby; a static type inference algorithm; a profiling-based analysis algorithm to handle hard-to-analyze dynamic constructs such as "eval"; interface files for modules; and an extension for analysis of Ruby-on-Rails code. We will discuss these features of DRuby and their evaluation, as well as lessons learned in working with scripting languages in general, and Ruby in particular. We will end by discussing future directions, including a symbolic execution engine for Ruby and user studies to better understand the use of types in programming.
Joint work with Mike Furr, Jong-hoon (David) An, Mike Hicks, Mark Daly, Avik Chaudhuri, and Ben Kirzhner.