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

Design and evaluation of gradual typing for python

Published: 14 October 2014 Publication History

Abstract

Combining static and dynamic typing within the same language offers clear benefits to programmers. It provides dynamic typing in situations that require rapid prototyping, heterogeneous data structures, and reflection, while supporting static typing when safety, modularity, and efficiency are primary concerns. Siek and Taha (2006) introduced an approach to combining static and dynamic typing in a fine-grained manner through the notion of type consistency in the static semantics and run-time casts in the dynamic semantics. However, many open questions remain regarding the semantics of gradually typed languages.
In this paper we present Reticulated Python, a system for experimenting with gradual-typed dialects of Python. The dialects are syntactically identical to Python 3 but give static and dynamic semantics to the type annotations already present in Python 3. Reticulated Python consists of a typechecker and a source-to-source translator from Reticulated Python to Python 3. Using Reticulated Python, we evaluate a gradual type system and three approaches to the dynamic semantics of mutable objects: the traditional semantics based on Siek and Taha (2007) and Herman et al. (2007) and two new designs. We evaluate these designs in the context of several third-party Python programs.

References

[1]
M. Abadi and L. Cardelli. phA Theory of Objects. Springer-Verlag, 1996.
[2]
M. Abadi, L. Cardelli, B. C. Pierce, and G. D. Plotkin. Dynamic typing in a statically-typed language. In phPOPL, pages 213--227, 1989.
[3]
A. Ahmed, R. B. Findler, J. G. Siek, and P. Wadler. Blame for all. In phPOPL '11: ACM SIGPLAN-SIGACT symposium on Principles of programming languages, POPL '11, pages 1--14, 2011.
[4]
Fabry, Tanter, and Denker}allende:2013gradualtalkE. Allende, O. Callaú, J. Fabry, E. Tanter, and M. Denker. Gradual typing for smalltalk. phScience of Computer Programming, August 2013.
[5]
G. Bierman, E. Meijer, and M. Torgersen. Adding dynamic types to C\#. In phEuropean Conference on Object-Oriented Programming, ECOOP'10. Springer-Verlag, 2010.
[6]
B. Bloom, J. Field, N. Nystrom, J. Östlund, G. Richards, R. Strnisa, J. Vitek, and T. Wrigstad. Thorn: Robust, concurrent, extensible scripting on the jvm. phSIGPLAN Not., 44 (10): 117--136, Oct. 2009. ISSN 0362--1340.
[7]
G. Bracha and D. Griswold. Strongtalk: typechecking Smalltalk in a production environment. In phOOPSLA '93: Proceedings of the eighth annual conference on Object-oriented programming systems, languages, and applications, pages 215--230, New York, NY, USA, 1993. ACM Press. ISBN 0--89791--587--9.
[8]
C. Chambers and the Cecil Group. The Cecil language: Specification and rationale. Technical report, Department of Computer Science and Engineering, University of Washington, Seattle, Washington, 2004.
[9]
T. V. Cutsem and M. S. Miller. Trustworthy proxies: virtualizing objects with invariants. In phProceedings of the 27th European Conference on Object-Oriented Programming, ECOOP'13, pages 154--178, Berlin, Heidelberg, 2013. Springer-Verlag. 10.1007/978--3--642--39038--8_7.
[10]
Facebook. Hack, 2011. URL http://hacklang.org.
[11]
R. B. Findler and M. Felleisen. Contracts for higher-order functions. Technical Report NU-CCS-02-05, Northeastern University, 2002.
[12]
Google. Dart: structured web apps, 2011. URL http://dartlang.org.
[13]
K. E. Gray, R. B. Findler, and M. Flatt. Fine-grained interoperability through mirrors and contracts. In phOOPSLA '05: Proceedings of the 20th annual ACM SIGPLAN conference on Object oriented programming systems languages and applications, pages 231--245, New York, NY, USA, 2005. ACM Press. ISBN 1--59593-031-0.
[14]
J. Gronski, K. Knowles, A. Tomb, S. N. Freund, and C. Flanagan. Sage: Hybrid checking for flexible specifications. In phScheme and Functional Programming Workshop, pages 93--104, 2006.
[15]
D. Herman, A. Tomb, and C. Flanagan. Space-efficient gradual typing. In phTrends in Functional Prog. (TFP), page XXVIII, April 2007.
[16]
L. Ina and A. Igarashi. Gradual typing for generics. In phACM Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA '11, 2011.
[17]
G. A. Kildall. A unified approach to global program optimization. In phPOPL '73: ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, pages 194--206. ACM Press, 1973.
[18]
B. S. Lerner, J. G. Politz, A. Guha, and S. Krishnamurthi. Tejas: Retrofitting type systems for JavaScript. In phSymposium on Dynamic Languages, DLS '13, pages 1--16, 2013.
[19]
E. Meijer and P. Drayton. Static typing where possible, dynamic typing when needed: The end of the cold war between programming languages. In phOOPSLA'04 Workshop on Revival of Dynamic Languages, 2004.
[20]
J. G. Politz, A. Martinez, M. Milano, S. Warren, D. Patterson, J. Li, A. Chitipothu, and S. Krishnamurthi. Python: The full monty. In phACM SIGPLAN Conference on Object Oriented Programming Systems Languages and Applications, OOPSLA '13, pages 217--232, 2013.
[21]
A. Rastogi, A. Chaudhuri, and B. Hosmer. The ins and outs of gradual type inference. In phACM SIGPLAN-SIGACT symposium on Principles of Programming Languages, POPL '12, 2012.
[22]
B. M. Ren, J. Toman, T. S. Strickland, and J. S. Foster. The ruby type checker. In phSAC'13 (OOPS), 2013.
[23]
G. Richards, C. Hammer, B. Burg, and J. Vitek. The eval that men do: A large-scale study of the use of eval in javascript applications. In phEuropean Conference on Object-Oriented Programming, ECOOP'11, pages 52--78, Berlin, Heidelberg, 2011.
[24]
M. Serrano. phBigloo: a practical Scheme compiler. Inria-Rocquencourt, April 2002.
[25]
J. G. Siek. Is typescript gradually typed? part 2, Oct. 2013. URL http://siek.blogspot.com/2012/10/is-typescript- gradually-typed-part-2.html.
[26]
J. G. Siek and W. Taha. Gradual typing for functional languages. In phScheme and Functional Programming Workshop, pages 81--92, September 2006.
[27]
J. G. Siek and W. Taha. Gradual typing for objects. In phECOOP 2007, volume 4609 of phLCNS, pages 2--27. Springer Verlag, August 2007.
[28]
J. G. Siek and P. Wadler. Threesomes, with and without blame. In phSymposium on Principles of Programming Languages, 2010.
[29]
J. G. Siek, R. Garcia, and W. Taha. Exploring the design space of higher-order casts. In phEuropean Symposium on Programming, March 2009.
[30]
A. Takikawa, T. S. Strickland, C. Dimoulas, S. Tobin-Hochstadt, and M. Felleisen. Gradual typing for first-class classes. In phConference on Object Oriented Programming Systems Languages and Applications, OOPSLA '12, pages 793--810, 2012.
[31]
S. Thatte. Quasi-static typing. In phPOPL 1990, pages 367--381, New York, NY, USA, 1990. ACM Press. ISBN 0--89791--343--4.
[32]
S. Tobin-Hochstadt and M. Felleisen. Interlanguage migration: From scripts to programs. In phOOPSLA'06 Companion, pages 964--974, NY, 2006. ACM.
[33]
S. Tobin-Hochstadt and M. Felleisen. The design and implementation of typed scheme. In phPOPL '08: the ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, 2008.
[34]
S. Tobin-Hochstadt and M. Felleisen. Logical types for untyped languages. In phACM SIGPLAN International Conference on Functional Programming, ICFP '10, pages 117--128, 2010.
[35]
P. Wadler and R. B. Findler. Well-typed programs can't be blamed. In phEuropean Symposium on Programming, 2009.
[36]
R. Wolff, R. Garcia, E. Tanter, and J. Aldrich. Gradual typestate. In phEuropean Conference on Object-Oriented Programming, ECOOP'11. Springer-Verlag, 2011.
[37]
T. Wrigstad, F. Z. Nardelli, S. Lebresne, J. Östlund, and J. Vitek. Integrating typed and untyped code in a scripting language. In phSymposium on Principles of Programming Languages, 2010.

Cited By

View all
  • (2024)Typed and Confused: Studying the Unexpected Dangers of Gradual TypingProceedings of the 39th IEEE/ACM International Conference on Automated Software Engineering10.1145/3691620.3695549(1858-1870)Online publication date: 27-Oct-2024
  • (2024)QuAC: Quick Attribute-Centric Type Inference for PythonProceedings of the ACM on Programming Languages10.1145/36897838:OOPSLA2(2040-2069)Online publication date: 8-Oct-2024
  • (2024)Nominal Types for ErlangProceedings of the 23rd ACM SIGPLAN International Workshop on Erlang10.1145/3677995.3678191(24-32)Online publication date: 28-Aug-2024
  • Show More Cited By

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image ACM Conferences
DLS '14: Proceedings of the 10th ACM Symposium on Dynamic languages
October 2014
160 pages
ISBN:9781450332118
DOI:10.1145/2661088
  • cover image ACM SIGPLAN Notices
    ACM SIGPLAN Notices  Volume 50, Issue 2
    DLS '14
    February 2015
    146 pages
    ISSN:0362-1340
    EISSN:1558-1160
    DOI:10.1145/2775052
    • Editor:
    • Andy Gill
    Issue’s Table of Contents
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 the author(s) 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].

Sponsors

In-Cooperation

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 14 October 2014

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. case study
  2. gradual typing
  3. proxy
  4. python

Qualifiers

  • Research-article

Conference

SPLASH '14
Sponsor:

Acceptance Rates

DLS '14 Paper Acceptance Rate 13 of 28 submissions, 46%;
Overall Acceptance Rate 32 of 77 submissions, 42%

Upcoming Conference

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)84
  • Downloads (Last 6 weeks)7
Reflects downloads up to 06 Nov 2024

Other Metrics

Citations

Cited By

View all
  • (2024)Typed and Confused: Studying the Unexpected Dangers of Gradual TypingProceedings of the 39th IEEE/ACM International Conference on Automated Software Engineering10.1145/3691620.3695549(1858-1870)Online publication date: 27-Oct-2024
  • (2024)QuAC: Quick Attribute-Centric Type Inference for PythonProceedings of the ACM on Programming Languages10.1145/36897838:OOPSLA2(2040-2069)Online publication date: 8-Oct-2024
  • (2024)Nominal Types for ErlangProceedings of the 23rd ACM SIGPLAN International Workshop on Erlang10.1145/3677995.3678191(24-32)Online publication date: 28-Aug-2024
  • (2024)Generating Python Type Annotations from Type Inference: How Far Are We?ACM Transactions on Software Engineering and Methodology10.1145/365215333:5(1-38)Online publication date: 3-Jun-2024
  • (2024)Type-Based Gradual Typing Performance OptimizationProceedings of the ACM on Programming Languages10.1145/36329318:POPL(2667-2699)Online publication date: 5-Jan-2024
  • (2024)Static Blame for gradual typingJournal of Functional Programming10.1017/S095679682400002934Online publication date: 25-Mar-2024
  • (2024)Gradual Typing Performance, Micro Configurations and Macro PerspectivesTheoretical Aspects of Software Engineering10.1007/978-3-031-64626-3_15(261-278)Online publication date: 29-Jul-2024
  • (2023)Transpilers: A Systematic Mapping Review of Their Usage in Research and IndustryApplied Sciences10.3390/app1306366713:6(3667)Online publication date: 13-Mar-2023
  • (2023)PyBartRec: Python API Recommendation with Semantic InformationProceedings of the 14th Asia-Pacific Symposium on Internetware10.1145/3609437.3609463(33-43)Online publication date: 4-Aug-2023
  • (2023)How to Evaluate Blame for Gradual Types, Part 2Proceedings of the ACM on Programming Languages10.1145/36078367:ICFP(159-186)Online publication date: 31-Aug-2023
  • Show More Cited By

View Options

Get Access

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media