In current programming language designs, flexibility and early error detection are typically seen as opposing forces. This is because flexibility is usually gained through dynamic typing, while early error detection is done through static types. Recently, a fair amount of research work has been done to try to bridge this gap by bringing some static safety guarantees to scripting languages.
The principal technique is a variant of type inference--frequently using ideas from abstract interpretation (explicitly or implicitly, as in this paper). Whether it is called soft typing, gradual typing, or contracts (see the paper for full references), a careful balancing act is needed: statically discover all errors that would produce an error at runtime versus falsely rejecting correct programs or burdening the programmer with the task of providing numerous annotations. This is the challenge that the authors tackle for Ruby.
The paper presents the general ideas behind the static type system, the constraint-based approach to type inference, cast insertion, and some implementation details. Additionally, some experimental results are presented and carefully analyzed. The authors’ conclusion is unsurprising: most production Ruby code that does not use “very dynamic” features can be fully analyzed, and few real bugs are found (but some are indeed found). The scalability to larger programs is not addressed.
The paper is written in a pleasant style and gives a good overview of DRuby. In particular, the various engineering challenges and pragmatic decisions are nicely presented. However, the lack of precise technical details leaves one wishing for a more expanded version. Although Furr et al. have published other papers on DRuby, none of them (as yet) seem to give a formal account of their work.