Dynamic Inference of Static Types for Ruby

dc.contributor.authorAn, Jong-hoon (David)
dc.contributor.authorChaudhuri, Avik
dc.contributor.authorFoster, Jeffrey S.
dc.contributor.authorHicks, Michael
dc.date.accessioned2010-07-29T03:33:31Z
dc.date.available2010-07-29T03:33:31Z
dc.date.issued2010-07-19
dc.description.abstractThere have been several efforts to bring static type inference to object-oriented dynamic languages such as Ruby, Python, and Perl. In our experience, however, such type inference systems are extremely difficult to develop, because dynamic languages are typically complex, poorly specified, and include features, such as eval and reflection, that are hard to analyze. In this paper, we introduce constraint-based dynamic type inference, a technique that infers static types based on dynamic program executions. In our approach, we wrap each run-time value to associate it with a type variable, and the wrapper generates constraints on this type variable when the wrapped value is used. This technique avoids many of the often overly conservative approximations of static tools, as constraints are generated based on how values are used during actual program runs. Using wrappers is also easy to implement, since we need only write a constraint resolution algorithm and a transformation to introduce the wrappers. The best part is that we can eat our cake, too: our algorithm will infer sound types as long as it observes every path through each method body—note that the number of such paths may be dramatically smaller than the number of paths through the program as a whole. We have developed Rubydust, an implementation of our algorithm for Ruby. Rubydust takes advantage of Ruby’s dynamic features to implement wrappers as a language library. We applied Rubydust to a number of small programs. We found it to be lightweight and useful: Rubydust discovered 1 real type error, and all other inferred types were correct, and readable.en_US
dc.identifier.urihttp://hdl.handle.net/1903/10599
dc.language.isoen_USen_US
dc.relation.ispartofseriesUM Computer Science Department;CS-TR-4965
dc.titleDynamic Inference of Static Types for Rubyen_US
dc.typeTechnical Reporten_US

Files

Original bundle
Now showing 1 - 1 of 1
Loading...
Thumbnail Image
Name:
CS-TR-4965.pdf
Size:
439.93 KB
Format:
Adobe Portable Document Format
License bundle
Now showing 1 - 1 of 1
No Thumbnail Available
Name:
license.txt
Size:
1.8 KB
Format:
Item-specific license agreed upon to submission
Description: