skip to main content
10.1145/2384616.2384674acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
research-article

Gradual typing for first-class classes

Published:19 October 2012Publication History

ABSTRACT

Dynamic type-checking and object-oriented programming often go hand-in-hand; scripting languages such as Python, Ruby, and JavaScript all embrace object-oriented (OO) programming. When scripts written in such languages grow and evolve into large programs, the lack of a static type discipline reduces maintainability. A programmer may thus wish to migrate parts of such scripts to a sister language with a static type system. Unfortunately, existing type systems neither support the flexible OO composition mechanisms found in scripting languages nor accommodate sound interoperation with untyped code. In this paper, we present the design of a gradual typing system that supports sound interaction between statically- and dynamically-typed units of class-based code. The type system uses row polymorphism for classes and thus supports mixin-based OO composition. To protect migration of mixins from typed to untyped components, the system employs a novel form of contracts that partially seal classes. The design comes with a theorem that guarantees the soundness of the type system even in the presence of untyped components.

References

  1. AHMED, A., FINDLER , R. B., SIEK , J. G., AND WADLER, P. Blame for all. In Symposium on Principles of Programming Languages (2011), pp. 201--214. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. BIERMAN, G., MEIJER, E., AND TORGERSEN, M. Adding dynamic types to C#. In European Conference on Object-Oriented Programming (2010), pp. 76--100. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. BONO, V., PATEL, A., AND SCHMATIKOV, V. A core calculus of classes and mixins. In European Conference on Object-Oriented Programming (1999), pp. 43--66. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. CARDELLI, L., AND MITCHELL , J. C. Operations on records. Mathematical Structures in Computer Science 1 (1991), 3--48.Google ScholarGoogle ScholarCross RefCross Ref
  5. DIMOULAS , C., F INDLER , R. B., F LANAGAN, C., AND FELLEISEN, M. Correct blame for contracts: No more scape-goating. In Symposium on Principles of Programming Languages (2011), pp. 215 -- 226. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. DIMOULAS , C., T OBIN-H OCHSTADT, S., AND FELLEISEN, M. Complete monitoring for behavioral contracts. In Euro-pean Symposium on Programming (2012), pp. 211--230. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. FELLEISEN, M., F INDLER , R. B., AND FLATT, M. Semantics Engineering with PLT Redex. MIT Press, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. FINDLER , R. B., C LEMENTS, J., F LANAGAN, C., F LATT, M., KRISHNAMURTHI, S., S TECKLER, P., AND FELLEISEN, M. DrScheme: A programming environment for Scheme. Journal of Functional Programming 12, 2 (2002), 159--182. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. FINDLER , R. B., AND FELLEISEN, M. Contracts for higher-order functions. In International Conference on Functional Programming (2002), pp. 48--59. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. FISHER , K. S. Type Systems for Object-Oriented Programming Languages. PhD thesis, Stanford University, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. FLATT, M., F INDLER , R. B., AND FELLEISEN, M. Scheme with classes, mixins, and traits. In Asian Symposium on Programming Languages and Systems (2006), pp. 270--289. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. FURR, M., A N, J.- H. D., F OSTER, J. S., AND HICKS , M. Static type inference for Ruby. In Symposium on Applied Computing (2009), pp. 1859--1866. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. GASTER, B. R., AND J ONES, M. P. A polymorphic type system for extensible records and variants. Technical Report NOTTCS-TR-96-3, University of Nottingham, 1996.Google ScholarGoogle Scholar
  14. GRAY, K. E. Safe cross-language inheritance. In European Conference on Object-Oriented Programming (2008), pp. 52--75. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. GRAY, K. E. Interoperability in a scripted world: Putting inheritance & prototypes together. In Foundations of Object-Oriented Languages (2011).Google ScholarGoogle Scholar
  16. GRAY, K. E., FINDLER , R. B., AND FLATT, M. Fine-grained interoperability through contracts and mirrors. In Object-Oriented Programming, Systems, Languages, and Applications (2005), pp. 231-245. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. GUHA, A., MATTHEWS, J., F INDLER , R. B., AND KRISH-NAMURTHI, S. Relationally-parametric polymorphic con-tracts. In Dynamic Languages Symposium (2007), pp. 29--40. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. HARPER, R., AND PIERCE , B. A records calculus based on symmetric concatenation. In Symposium on Principles of Programming Languages (1991), pp. 131--142. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. HERMAN, D., AND FLANAGAN, C. Status report: Specifying JavaScript with ML. In ML Workshop (2007). Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. LAMPING, J. Typing the specialization interface. In Object-Oriented Programming, Systems, Languages, and Applications (1993), pp. 201--214. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. MATTHEWS, J., AND AHMED, A. Parametric polymorphism through run-time sealing, or, theorems for low, low prices! In European Symposium on Programming (2008), pp. 16--31. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. MATTHEWS, J., AND FINDLER , R. B. The meaning of multi-language programs. In Symposium on Principles of Programming Languages (2007), pp. 3--10.Google ScholarGoogle Scholar
  23. MEJER, E., AND DRAYTON, P. Static typing where possible, dynamic typing when needed: The end of the cold war between programming languages. In OOPSLA Workshop on Revival of Dynamic Languages (2004).Google ScholarGoogle Scholar
  24. MORRIS, J R., J. H. Types are not sets. In Symposium on Principles of Programming Languages (1973), pp. 120--124. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. PIERCE , B., AND SUMII, E. A bisimulation for dynamic sealing. In Symposium on Principles of Programming Languages (2004), pp. 161--172. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. REMY, D. Programming objects with ML-ART an extension to ML with abstract and record types. In Theoretical Aspects of Computer Software (1994), pp. 321--346. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. SIEK , J., AND TAHA, W. Gradual typing for functional languages. In Workshop on Scheme and Functional Programming (2006), pp. 81--92.Google ScholarGoogle Scholar
  28. SIEK , J., AND TAHA, W. Gradual typing for objects. In European Conference on Object-Oriented Programming (2007), pp. 2--27. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. STRICKLAND, T. S., AND FELLEISEN, M. Contracts for first-class classes. In Dynamic Languages Symposium (2010), pp. 97--111. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. TAKIKAWA, A., S TRICKLAND, T. S., D IMOULAS , C., TOBIN-H OCHSTADT, S., AND FELLEISEN, M. Gradual typ-ing for first-class classes. Technical Report NU-CCIS-12-02, Northeastern University, College of Computer and Information Science, 2012.Google ScholarGoogle Scholar
  31. TANG, A. Perl 6: reconciling the irreconcilable. Symposium on Principles of Programming Languages, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. TOBIN-HOCHSTADT, S., AND FELLEISEN, M. Interlanguage migration: from scripts to programs. In Dynamic Languages Symposium (2006), pp. 964-974. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. TOBIN-HOCHSTADT, S., AND FELLEISEN, M. The design and implementation of Typed Scheme. In Symposium on Principles of Programming Languages (2008), pp. 395--406. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. TOBIN-HOCHSTADT, S., AND FELLEISEN, M. Logical types for untyped languages. In International Conference on Functional Programming (2010), pp. 117--128. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. WAND, M. Complete type inference for simple objects. In Symposium on Logic in Computer Science (1987).Google ScholarGoogle Scholar
  36. WAND, M. Type inference for objects with instance variables and inheritance. In Theoretical Aspects of Object-Oriented Programming (1994), pp. 97--120. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. WRIGHT, A. K., AND FELLEISEN, M. A syntactic approach to type soundness. Information and Control (1994), 38--94. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. WRIGSTAD, T., NARDELLI, F. Z., L EBRESNE, S., OSTLUND, J., AND VITEK , J. Integrating typed and untyped code in a scripting language. In Symposium on Principles of Programming Languages (2010), pp. 377--388. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Gradual typing for first-class classes

    Recommendations

    Comments

    Login options

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

    Sign in
    • Published in

      cover image ACM Conferences
      OOPSLA '12: Proceedings of the ACM international conference on Object oriented programming systems languages and applications
      October 2012
      1052 pages
      ISBN:9781450315616
      DOI:10.1145/2384616
      • cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 47, Issue 10
        OOPSLA '12
        October 2012
        1011 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/2398857
        Issue’s Table of Contents

      Copyright © 2012 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 19 October 2012

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • research-article

      Acceptance Rates

      Overall Acceptance Rate268of1,244submissions,22%

      Upcoming Conference

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader