skip to main content
research-article

Gradual typing for generics

Published:22 October 2011Publication History
Skip Abstract Section

Abstract

Gradual typing is a framework to combine static and dynamic typing in a single programming language. In this paper, we develop a gradual type system for class-based object-oriented languages with generics. We introduce a special type to denote dynamically typed parts of a program; unlike dynamic types introduced to C# 4.0, however, our type system allows for more seamless integration of dynamically and statically typed code.

We formalize a gradual type system for Featherweight GJ with a semantics given by a translation that inserts explicit run-time checks. The type system guarantees that statically typed parts of a program do not go wrong, even if it includes dynamically typed parts. We also describe a basic implementation scheme for Java and report preliminary performance evaluation.

References

  1. M. Abadi, L. Cardelli, B. Pierce, and G. Plotkin. Dynamic typing in a statically typed language. ACM Trans. Prog. Lang. Syst., 13 (2): 237--268, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. A. Ahmed, R. B. Findler, J. G. Siek, and P. Wadler. Blame for all. In Proc. of ACM POPL'11, pages 201--214, Austin, TX, Jan. 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. C. Anderson and S. Drossopoulou. BabyJ - from object based to class based programming via types. In Proc. of WOOD'03, volume 82 of Elsevier ENTCS, pages 53--81, 2003.Google ScholarGoogle Scholar
  4. G. Bierman, E. Meijer, and M. Torgersen. Adding dynamic types to \Csharp. In Proc. of ECOOP'10, volume 6183 of Springer LNCS, pages 76--100, Maridbor, Slovenia, June 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. B. Bloom, J. Field, N. Nystrom, J. Östlund, G. Richards, R. Strni\v sa, J. Vitek, and T. Wrigstad. Thorn -- robust, concurrent, extensible scripting on the JVM. In Proc. of ACM OOPSLA'09, pages 117--136, Orlando, FL, Oct. 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. G. Bracha and D. Griswold. Strongtalk: Typechecking Smalltalk in a production environment. In Proc. of ACM OOPSLA'93, pages 215--230, 1993. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. G. Bracha, M. Odersky, D. Stoutamire, and P. Wadler. Making the future safe for the past: Adding genericity to the Java programming language. In Proc. of ACM OOPSLA'98, pages 183--200, Vancouver, BC, Oct. 1998. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. R. Cartwright and M. Fagan. Soft typing. In Proc. of ACM PLDI'91, pages 278--292, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. R. B. Findler and M. Felleisen. Contracts for higher-order functions. In Proc. of ACM ICFP'02, pages 48--59, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. C. Flanagan. Hybrid type checking. In Proc. of ACM POPL'06, pages 245--256, Charleston, SC, Jan. 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. M. Furr, J. An, J. S. Foster, and M. Hicks. Static type inference for Ruby. In Proc. of ACM Symposium on Applied Computing (SAC'09), pages 1859--1866, Mar. 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. K. E. Gray. Safe cross-language inheritance. In Proc. of ECOOP'08, volume 5142 of Springer LNCS, pages 52--75, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. K. E. Gray. Interoperability in a scripted world: Putting inheritance & prototypes together. In Proc. of FOOL'10, Oct. 2010.Google ScholarGoogle Scholar
  14. K. E. Gray, R. B. Findler, and M. Flatt. Fine-grained interoperability through mirrors and contracts. In Proc. of ACM OOPSLA'05, pages 231--245, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. J. Gronski, K. Knowles, A. Tomb, S. N. Freund, and C. Flanagan. Sage: Hybrid checking for flexible specifications. In Proc. of the Scheme and Functional Programming Workshop, pages 93--104, Sept. 2006.Google ScholarGoogle Scholar
  16. F. Henglein. Dynamic typing. In Proc. of ESOP'92, volume 582 of Springer LNCS, pages 233--253, Rennes, France, Feb. 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. A. Igarashi and M. Viroli. Variant parametric types: A flexible subtyping scheme for generics. ACM Trans. Prog. Lang. Syst., 28 (5): 795--847, Sept. 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. A. Igarashi, B. C. Pierce, and P. Wadler. Featherweight Java: A minimal core calculus for Java and GJ. ACM Trans. Prog. Lang. Syst., 23 (3): 396--450, May 2001. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. }InaIgarashi09STOPL. Ina and A. Igarashi. Towards gradual typing for generics. In Proc. of STOP'09, pages 17--29, Genova, Italy, July 2009\natexlaba. Available also in the ACM Digital Library. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. }ina09:fjgradL. Ina and A. Igarashi. Gradual typing for Featherweight Java. Computer Software, 26 (2): 18--40, Apr. 2009\natexlabb. In Japanese.Google ScholarGoogle Scholar
  21. A. J. Kennedy and B. C. Pierce. On decidability of nominal subtyping with variance. In Proc. of FOOL/WOOD'07, Nice, France, Jan. 2007.Google ScholarGoogle Scholar
  22. G. Lagorio and E. Zucca. Just: safe unknown types in Java-like languages. Journal of Object Technology, 6 (2): 69--98, Feb. 2007.Google ScholarGoogle ScholarCross RefCross Ref
  23. B. H. Liskov and J. M. Wing. A behavioral notion of subtyping. ACM Trans. Prog. Lang. Syst., 16 (6): 1811--1841, Nov. 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. J. Matthews and A. Ahmed. Parametric polymorphism through run-time sealing, or, thorems for low, low prices! In Proc. of ESOP'08, volume 4960 of Springer LNCS, pages 16--31, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. M. Odersky and P. Wadler. Pizza into Java: Translating theory into practice. In Proc. of ACM POPL'97, pages 146--159, Jan. 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. I. Sergey and D. Clarke. Towards gradual ownership types. In Proc. of IWACO'11, Lancaster, UK, July 2011.Google ScholarGoogle Scholar
  27. J. G. Siek and W. Taha. Gradual typing for functional languages. In Proc. of the Scheme and Functional Programming Workshop, pages 81--92, Sept. 2006.Google ScholarGoogle Scholar
  28. J. G. Siek and W. Taha. Gradual typing for objects. In Proc. of ECOOP'07, volume 4509 of Springer LNCS, pages 2--27, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. S. Thatte. Quasi-static typing. In Proc. of ACM POPL'90, pages 367--381, Jan. 1990. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. P. Thiemann. Towards a type system for analyzing JavaScript programs. In Proc. of ESOP'09, volume 3444 of Springer LNCS, pages 408--422, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. M. Torgersen, E. Ernst, C. P. Hansen, P. von der Ahé, G. Bracha, and N. Gafter. Adding wildcards to the Java programming language. Journal of Object Technology, 3 (11): 97--116, Dec. 2004. Special issue: OOPS track at SAC 2004.Google ScholarGoogle ScholarCross RefCross Ref
  32. M. Viroli. A type-passing approach for the implementation of parametric methods in Java. The Computer Journal, 46 (3): 263--294, 2003.Google ScholarGoogle ScholarCross RefCross Ref
  33. M. Viroli. Effective and efficient compilation of run-time generics in Java. In Proc. of WOOD'04, volume 138 of Elsevier ENTCS, pages 95--116, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. M. Viroli and A. Natali. Parametric polymorphism in Java: An approach to translation based on reflective features. In Proc. of ACM OOPSLA'00, pages 146--165, Oct. 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. P. Wadler and R. B. Findler. Well-typed programs can't be blamed. In Proc. of ESOP'09, volume 5502 of Springer LNCS, pages 1--16, York, UK, Mar. 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. R. Wolff, R. Garcia, É. Tanter, and J. Aldrich. Gradual typestate. In Proc. of ECOOP'11, volume 6813 of Springer LNCS, pages 459--483, Lancaster, UK, July 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. A. K. Wright and M. Felleisen. A syntactic approach to type soundness. Information and Computation, 115 (1): 38--94, Nov. 1994. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. T. Wrigstad, F. Z. Nardelli, S. Lebresne, J. Östlund, and J. Vitek. Integrating typed and untyped code in a scripting language. In Proc. of ACM POPL'10, pages 377--388, 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Gradual typing for generics

        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

        Full Access

        • Published in

          cover image ACM SIGPLAN Notices
          ACM SIGPLAN Notices  Volume 46, Issue 10
          OOPSLA '11
          October 2011
          1063 pages
          ISSN:0362-1340
          EISSN:1558-1160
          DOI:10.1145/2076021
          Issue’s Table of Contents
          • cover image ACM Conferences
            OOPSLA '11: Proceedings of the 2011 ACM international conference on Object oriented programming systems languages and applications
            October 2011
            1104 pages
            ISBN:9781450309400
            DOI:10.1145/2048066

          Copyright © 2011 ACM

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 22 October 2011

          Check for updates

          Qualifiers

          • research-article

        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!