The increasing popularity of dynamically typed languages--such as JavaScript, Ruby, and Smalltalk--pressures their associated community to produce better tools for program comprehension and verification. Automatically extracting type information for a program written in a dynamically typed language is a win-win approach--language designers can keep their language untouched and users do not need to change their habits to obtain type information.
The work presented here makes a significant contribution in this respect. The authors’ idea relies on a static analysis of messages sent to variables. The type of a variable is deduced from the set of messages sent in the class that defines the variable. In addition to this, several simple but effective heuristics based on variable assignment are provided to enhance the accuracy of the analysis. This type reconstruction schema is reasonably precise, with a matching of 75 percent of the real type found at execution.
The proposed type reconstruction mechanism copes with the severe practical requirements of an open-source software community. The language extension is distributed as an external library, making loading and unloading easy. In addition, it is very fast, and is noninvasive with regard to other language extensions and tools. The implementation is part of the standard Pharo Smalltalk distribution that reaches a significant number of end users and developers.
The paper should be very valuable to any dynamic or scripting language designer who wishes to implement a useful and practical language enhancement.