skip to main content
research-article

Fast type reconstruction for dynamically typed programming languages

Authors Info & Claims
Published:26 October 2009Publication History
Skip Abstract Section

Abstract

Type inference and type reconstruction derive static types for program elements that have no static type associated with them. They have a wide range of usage, such as helping to eliminate the burden of manually specifying types, verifying whether a program is type-safe, helping to produce more optimized code or helping to understand programs. While type inference and type reconstruction is an active field of research, most existing techniques are interested foremost in the precision of their approaches, at the expense of execution speed. As a result, existing approaches are not suited to give direct feedback in development environments, where interactivity dictates very fast approaches. This paper presents a type reconstruction algorithm for variables that is extremely fast (in the order of milliseconds) and reasonably precise (75 percent). The system is implemented as a byte-code evaluator in several Smalltalk environments, and its execution speed and precision are validated on a number of concrete case studies.

References

  1. O. Agesen. The cartesian product algorithm. In W. Olthoff, editor, Proceedings ECOOP '95, volume 952 of LNCS, pages 2--26, Aarhus, Denmark, Aug. 1995. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. G. Bracha and D. Griswold. Strongtalk: Typechecking Smalltalk in a production environment. In Proceedings OOPSLA '93, ACM SIGPLAN Notices, volume 28, pages 215--230, Oct. 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. L. Cardelli. Type systems. In A. B. Tucker, editor, The Computer Science and Engineering Handbook, chapter 103, pages 2208--2236. CRC Press, Boca Raton, FL, 1997.Google ScholarGoogle Scholar
  4. Chailloux. Développement d'applications avec Objective CAML. O'Reilly, 2000.Google ScholarGoogle Scholar
  5. M. Furr, J. hoon (David) An, J. S. Foster, and M. Hicks. Static type inference for ruby. To appear in OOPS track, SAC 2009, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. E. Gamma, R. Helm, R. Johnson, and J. Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Addison Wesley, Reading, Mass., 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. K. Mens, I. Michiels, and R. Wuyts. Supporting software development through declaratively codified programming patterns. SEKE 2001 Special Issue of Elsevier Journal on Expert Systems with Applications, 2001.Google ScholarGoogle Scholar
  8. J. Palsberg and M. I. Schwartzbach. Object-oriented type inference. In Proceedings OOPSLA '91, ACM SIGPLAN Notices, volume 26, pages 146--161, Nov. 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. L. Paulson. ML for the Working Programmer. Cambridge University Press, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. R. Robbes and M. Lanza. How program history can improve code completion. In ASE: 23rd IEEE/ACM International Conference on Automated Software Engineering (ASE 2008), 15-19 September 2008, L'Aquila, Italy, pages 317--326, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. M. Salib. Starkiller: A static type inferencer and compiler for python. Master's thesis, Massachusetts Institute of Technology, may 2004.Google ScholarGoogle Scholar
  12. The scala programming language. http://lamp.epfl.ch/scala/.Google ScholarGoogle Scholar
  13. S. A. Spoon and O. Shivers. Demand-driven type inference with subgoal pruning: Trading precision for scalability. In Proceedings of ECOOP'04, pages 51--74, 2004.Google ScholarGoogle ScholarCross RefCross Ref
  14. S. A. Spoon and O. Shivers. Dynamic data polyvariance using source-tagged classes. In R. Wuyts, editor, Proceedings of the Dynamic Languages Symposium'05, pages 35--48. ACM Digital Library, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. S. Thompson. Haskell: The Craft of Functional Programming (2nd edition). Addison Wesley, Reading, Mass., 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. T. Wang and S. F. Smith. Precise constraint-based type inference for java. In G. Goos, J. Hartmanis, and J. van Leeuwen, editors, Proceedings ECOOP '01, volume 2072 of LNCS, pages 99--118, Budapest, Hungary, June 2001. Springer-Verlag. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Fast type reconstruction for dynamically typed programming languages

    Recommendations

    Reviews

    Alexandre Bergel

    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. Online Computing Reviews Service

    Access critical reviews of Computing literature here

    Become a reviewer for Computing Reviews.

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in

    Full Access

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader
    About Cookies On This Site

    We use cookies to ensure that we give you the best experience on our website.

    Learn more

    Got it!