skip to main content
research-article

Cast insertion strategies for gradually-typed objects

Published:28 October 2013Publication History
Skip Abstract Section

Abstract

Gradual typing enables a smooth and progressive integration of static and dynamic typing. The semantics of a gradually-typed program is given by translation to an intermediate language with casts: runtime type checks that control the boundaries between statically- and dynamically-typed portions of a program. This paper studies the performance of different cast insertion strategies in the context of Gradualtalk, a gradually-typed Smalltalk. We first implement the strategy specified by Siek and Taha, which inserts casts at call sites. We then study the dual approach, which consists in performing casts in callees. Based on the observation that both strategies perform well in different scenarios, we design a hybrid strategy that combines the best of each approach. We evaluate these three strategies using both micro- and macro-benchmarks. We also discuss the impact of these strategies on memory, modularity, and inheritance. The hybrid strategy constitutes a promising cast insertion strategy for adding gradual types to existing dynamically-typed languages.

References

  1. R. Cartwright, M. Fagan, Soft typing, in: Proceedings of the ACM SIGPLAN 1991 conference on Programming language design and implementation, PLDI '91, 1991, pp. 278--292. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. G. Bracha, D. Griswold, Strongtalk: Typechecking Smalltalk in a production environment, in: Proceedings of the 8th International Conference on Object-Oriented Programming Systems, Languages and Applications (OOPSLA 95), ACM Press, Washington, D.C., USA, 1993, pp. 215--230, aCM SIGPLAN Notices, 28(10). Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. G. Bracha, Pluggable type systems, in: OOPSLA Workshop on Revival of Dynamic Languages, 2004, pp. 1--6.Google ScholarGoogle Scholar
  4. K. Knowles, C. Flanagan, Hybrid type checking, ACM Transactions on Programming Languages and Systems 32 (2) (2010) Article n.6. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. S. Tobin-Hochstadt, Typed Scheme: From Scripts to Programs, Ph.D. thesis, Northeastern University (Jan. 2010).Google ScholarGoogle Scholar
  6. M. Furr, Combining static and dynamic typing in Ruby, Ph.D. thesis, University of Maryland (2009).Google ScholarGoogle Scholar
  7. A. Rastogi, A. Chaudhuri, B. Hosmer, The ins and outs of gradual type inference, in: Proceedings of the 39th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages (POPL 2012), ACM Press, Philadelphia, USA, 2012, pp. 481--494. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. J. Siek, W. Taha, Gradual typing for functional languages, in: Proceedings of the Scheme and Functional Programming Workshop, 2006, pp. 81--92.Google ScholarGoogle Scholar
  9. J. Siek, W. Taha, Gradual typing for objects, in: E. Ernst (Ed.), Proceedings of the 21st European Conference on Object-oriented Programming (ECOOP 2007), no. 4609 in Lecture Notes in Computer Science, Springer-Verlag, Berlin, Germany, 2007, pp. 2--27. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. A. Goldberg, D. Robson, Smalltalk-80: The Language and its Implementation, Addison-Wesley, 1983. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. P. Wadler, R. B. Findler, Well-typed programs can't be blamed, in: ESOP 2009, pp. 1--16. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. C. Saito, A. Igarashi, hrefhttp://doi.acm.org/10.1145/1640089.1640109Self type constructors, in: Proceedings of the 24th ACM SIGPLAN conference on Object oriented programming systems languages and applications, OOPSLA '09, ACM, New York, NY, USA, 2009, pp. 263--282.href http://dx.doi.org/10.1145/1640089.1640109pathdoi:10.1145/1640089.1640109. http://doi.acm.org/10.1145/1640089.1640109 Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. R. B. Findler, M. Felleisen, Contracts for higher-order functions, in: Proceedings of the 7th ACM SIGPLAN International Conference on Functional Programming, ACM Press, Pittsburgh, PA, USA, 2002, pp. 48--59. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. J. Siek, R. Garcia, W. Taha, Exploring the design space of higher-order casts, in: ESOP 2009, pp. 17--31. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. B. C. Pierce, Types and programming languages, MIT Press, Cambridge, MA, USA, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. L. Ina, A. Igarashi, Gradual typing for generics, in: Proceedings of the 26th ACM SIGPLAN Conference on Object-Oriented Programming Systems, Languages and Applications (OOPSLA 2011), ACM Press, Portland, Oregon, USA, 2011, pp. 609--624. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. S. Tobin-Hochstadt, M. Felleisen, Logical types for untyped languages, in: Proceedings of the 15th ACM SIGPLAN Conference on Functional Programming (ICFP 2010), ACM Press, Baltimore, Maryland, USA, 2010, pp. 117--128. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. A. Guha, C. Saftoiu, S. Krishnamurthi, Typing local control and state using flow analysis, in: G. Barthe (Ed.), Proceedings of the 20th European Symposium on Programming (ESOP 2011), Vol. 6602 of Lecture Notes in Computer Science, Springer-Verlag, 2011, pp. 256--275. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. N. Schärli, S. Ducasse, O. Nierstrasz, A. Black, Traits: Composable units of behavior, in: L. Cardelli (Ed.), Proceedings of the 17th European Conference on Object-Oriented Programming (ECOOP 2003), no. 2743 in Lecture Notes in Computer Science, Springer-Verlag, Darmstadt, Germany, 2003, pp. 248--274.Google ScholarGoogle ScholarCross RefCross Ref
  20. D. Malayeri, J. Aldrich, Integrating nominal and structural subtyping, in: J. Vitek (Ed.), Proceedings of the 22nd European Conference on Object-oriented Programming (ECOOP 2008), no. 5142 in Lecture Notes in Computer Science, Springer-Verlag, Paphos, Cyprus, 2008, pp. 260--284. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. D. Malayeri, J. Aldrich, Is structural subtyping useful? an empirical study, in: ESOP 2009, pp. 95--111. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. D. Doligez, A. Frisch, J. Garrigue, D. Rémy, J. Vouillon, The OCaml system release 3.12, Institut National de Recherche en Informatique et en Automatique, http://caml.inria.fr/pub/docs/manual-ocaml/index.html (Jul 2011).Google ScholarGoogle Scholar
  23. É. P. F. de Lausanne (EPFL), Scala, http://www.scala-lang.org.Google ScholarGoogle Scholar
  24. L. Cardelli, Type systems, in: A. B. Tucker (Ed.), The Computer Science and Engineering Handbook, CRC Press, 1997, Ch. 103, pp. 2208--2236.Google ScholarGoogle Scholar
  25. O. Callaú, É. Tanter, Programming with ghosts, IEEE Software 30 (1) (2013) 74--80. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. R. Wolff, R. Garcia, É. Tanter, J. Aldrich, Gradual typestate, in: M. Mezini (Ed.), Proceedings of the 25th European Conference on Object-oriented Programming (ECOOP 2011), Vol. 6813 of Lecture Notes in Computer Science, Springer-Verlag, Lancaster, UK, 2011, pp. 459--483. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. G. Bracha, The strongtalk type system for smalltalk, http://www.bracha.org/nwst.html.Google ScholarGoogle Scholar
  28. R. Smit, Pegon, http://sourceforge.net/projects/pegon/.Google ScholarGoogle Scholar
  29. S. Tobin-Hochstadt, V. St-Amour, The typed racket guide, http://docs.racket-lang.org/ts-guide/.Google ScholarGoogle Scholar
  30. I. Figueroa, É. Tanter, N. Tabareau, A practical monadic aspect weaver, in: Proceedings of the 11th Workshop on Foundations of Aspect-Oriented Languages (FOAL 2012), ACM Press, Potsdam, Germany, 2012, pp. 21--26. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. R. E. Johnson, Type-checking smalltalk, SIGPLAN Not. 21 (11) (1986) 315--321. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. R. E. Johnson, J. O. Graver, L. W. Zurawski, Ts: an optimizing compiler for smalltalk, SIGPLAN Not. 23 (11) (1988) 18--26. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. J. O. Graver, R. E. Johnson, A type system for smalltalk, in: POPL '90: Proceedings of the 17th ACM SIGPLAN-SIGACT symposium on Principles of programming languages, 1990, pp. 136--150. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. N. Haldiman, M. Denker, O. Nierstrasz, Practical, pluggable types for a dynamic language, Comput. Lang. Syst. Struct. 35 (1) (2009) 48--62. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. F. Pluquet, A. Marot, R. Wuyts, Fast type reconstruction for dynamically typed programming languages, in: DLS '09: Proceedings of the 5th symposium on Dynamic languages, 2009, pp. 69--78. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. D. Ancona, M. Ancona, A. Cuni, N. D. Matsakis, Rpython: a step towards reconciling dynamically and statically typed oo languages, in: Proceedings of the 2007 symposium on Dynamic languages, DLS '07, 2007, pp. 53--64. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. C. Anderson, S. Drossopoulou, P. Giannini, Towards type inference for javascript, in: A. P. Black (Ed.), Proceedings of the 19th European Conference on Object-Oriented Programming (ECOOP 2005), no. 3586 in Lecture Notes in Computer Science, Springer-Verlag, Glasgow, UK, 2005, pp. 428--452. Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. T. Wrigstad, F. Zappa Nardelli, S. Lebresne, J. Östlund, J. Vitek, Integrating typed and untyped code in a scripting language, in: POPL 2010, pp. 377--388. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. D. Herman, A. Tomb, C. Flanagan, Space-efficient gradual typing, Higher-Order and Sympolic Computation 23 (2) (2010) 167--189. Google ScholarGoogle ScholarDigital LibraryDigital Library
  40. J. Siek, P. Wadler, Threesomes, with and without blame, in: POPL 2010, pp. 365--376. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. Proceedings of the 18th European Symposium on Programming Languages and Systems (ESOP 2009), Vol. 5502 of Lecture Notes in Computer Science, Springer-Verlag, York, UK, 2009.Google ScholarGoogle Scholar
  42. Proceedings of the 37th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages (POPL 2010), ACM Press, Madrid, Spain, 2010.Google ScholarGoogle Scholar

Index Terms

  1. Cast insertion strategies for gradually-typed objects

    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 49, Issue 2
      DLS '13
      February 2014
      105 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/2578856
      Issue’s Table of Contents
      • cover image ACM Conferences
        DLS '13: Proceedings of the 9th symposium on Dynamic languages
        October 2013
        118 pages
        ISBN:9781450324335
        DOI:10.1145/2508168

      Copyright © 2013 ACM

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 28 October 2013

      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!