Skip to main content

Gradual Typing Performance, Micro Configurations and Macro Perspectives

  • Conference paper
  • First Online:
Theoretical Aspects of Software Engineering (TASE 2024)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 14777))

Included in the following conference series:

  • 449 Accesses

Abstract

Static typing and dynamic typing have respective strengths and weaknesses, and a language often commits to one typing discipline and inherits the qualities, good or bad. Gradual typing has been developed to reconcile these typing disciplines, allowing a single program to mix both static and dynamic typing. It protects soundness of typed regions with runtime checks when values flown into them do not have required static types. One issue with gradual typing is that such checks can incur significant performance overhead. Previous work on performance has focused on coarse-grained gradual typing where each module (file) has to be fully typed or untyped. In contrast, the performance of fine-grained gradual typing where each single parameter can be partially-typed (such as specifying the parameter as a list without giving element type) has not been investigated.

Motivated by this situation, this paper systematically investigates performance of fine-grained gradual typing by studying the performance of more than 1 million programs. These programs are drawn from seven commonly-used benchmarks with different types for parameters: some parameters are untyped, some are statically typed, and others are partially statically typed. The paper observes many interesting phenomena that were previously unknown to the research community. They provide insights into future research directions of understanding, predicting, and optimizing gradual typing performance as well as migrating gradual programs towards more static.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
$34.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

Notes

  1. 1.

    \(2\times 2\times 3=12\), but we need to minus one combination whose all components are static.

  2. 2.

    https://docs.python.org/3/library/typing.html.

References

  1. Allamanis, M., Barr, E.T., Ducousso, S., Gao, Z.: Typilus: neural type hints. In: Proceedings of the 41st ACM SIGPLAN Conference on Programming Language Design and Implementation. ACM (2020). https://doi.org/10.1145/3385412.3385997

  2. Campora, J., Chen, S., Erwig, M., Walkingshaw, E.: Migrating gradual types. In: Proceedings of the 45th ACM SIGPLAN Symposium on Principles of Programming Languages, POPL 2018. ACM, New York (2018)

    Google Scholar 

  3. Campora, J.P., Chen, S.: Taming type annotations in gradual typing. Proc. ACM Program. Lang. 4(OOPSLA) (2020). https://doi.org/10.1145/3428259

  4. Campora, J.P., Chen, S., Walkingshaw, E.: Casts and costs: harmonizing safety and performance in gradual typing. Proc. ACM Program. Lang. 2(ICFP), 98:1–98:30 (2018). https://doi.org/10.1145/3236793

  5. Campora, J.P., Khan, M.W., Chen, S.: Type-based gradual typing performance optimization. Proc. ACM Program. Lang. 8(POPL) (2024). https://doi.org/10.1145/3632931

  6. Castagna, G., Lanvin, V., Petrucciani, T., Siek, J.G.: Gradual typing: a new perspective. Proc. ACM Program. Lang. 3(POPL) (2019). https://doi.org/10.1145/3290329

  7. Chandra, S., et al.: Type inference for static compilation of JavaScript. In: Proceedings of the 2016 ACM SIGPLAN International Conference on Object-Oriented Programming, Systems, Languages, and Applications, OOPSLA 2016, pp. 410–429. ACM, New York (2016). https://doi.org/10.1145/2983990.2984017

  8. Chaudhuri, A., Vekris, P., Goldman, S., Roch, M., Levi, G.: Fast and precise type checking for JavaScript. Proc. ACM Program. Lang. 1(OOPSLA), 48:1–48:30 (2017). https://doi.org/10.1145/3133872

  9. Cristiani, F., Thiemann, P.: Generation of typescript declaration files from JavaScript code. In: Proceedings of the 18th ACM SIGPLAN International Conference on Managed Programming Languages and Runtimes, MPLR 2021, pp. 97–112. Association for Computing Machinery, New York (2021). https://doi.org/10.1145/3475738.3480941

  10. Feldthaus, A., Møller, A.: Checking correctness of typescript interfaces for JavaScript libraries. SIGPLAN Not. 49(10), 1–16 (2014). https://doi.org/10.1145/2714064.2660215

    Article  MATH  Google Scholar 

  11. Feltey, D., Greenman, B., Scholliers, C., Findler, R.B., St-Amour, V.: Collapsible contracts: fixing a pathology of gradual typing. Proc. ACM Program. Lang. 2(OOPSLA) (2018). https://doi.org/10.1145/3276503

  12. Greenman, B.: GTP benchmarks for gradual typing performance. In: Proceedings of the 2023 ACM Conference on Reproducibility and Replicability, ACM REP 2023, pp. 102–114. Association for Computing Machinery, New York (2023). https://doi.org/10.1145/3589806.3600034

  13. Greenman, B., et al.: How to evaluate the performance of gradual type systems. J. Funct. Program. 29, e4 (2019). https://doi.org/10.1017/S0956796818000217

    Article  MathSciNet  MATH  Google Scholar 

  14. Kristensen, E.K., Møller, A.: Type test scripts for typescript testing. Proc. ACM Program. Lang. 1(OOPSLA), 90:1–90:25 (2017). https://doi.org/10.1145/3133914

  15. Kuhlenschmidt, A., Almahallawi, D., Siek, J.G.: Toward efficient gradual typing for structural types via coercions. In: Proceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI 2019, pp. 517–532. Association for Computing Machinery, New York (2019). https://doi.org/10.1145/3314221.3314627

  16. Migeed, Z., Palsberg, J.: What is decidable about gradual types? Proc. ACM Program. Lang. 4(POPL) (2019). https://doi.org/10.1145/3371097

  17. Mir, A.M., Latoškinas, E., Proksch, S., Gousios, G.: Type4Py: practical deep similarity learning-based type inference for python. In: Proceedings of the 44th International Conference on Software Engineering, pp. 2241–2252 (2022)

    Google Scholar 

  18. Miyazaki, Y., Sekiyama, T., Igarashi, A.: Dynamic type inference for gradual Hindley–Milner typing. Proc. ACM Program. Lang. 3(POPL), 18:1–18:29 (2019). https://doi.org/10.1145/3290331

  19. Moy, C., Nguy\(\sim \)ĂŞn, P.C., Tobin-Hochstadt, S., Van Horn, D.: Corpse reviver: sound and efficient gradual typing via contract verification. Proc. ACM Program. Lang. 5(POPL) (2021). https://doi.org/10.1145/3434334

  20. Ortin, F., Garcia, M., McSweeney, S.: Rule-based program specialization to optimize gradually typed code. Knowl.-Based Syst. 179, 145–173 (2019). https://doi.org/10.1016/j.knosys.2019.05.013

    Article  MATH  Google Scholar 

  21. Peng, Y., et al.: Static inference meets deep learning: a hybrid type inference approach for python. In: Proceedings of the 44th International Conference on Software Engineering, ICSE 2022, pp. 2019–2030. Association for Computing Machinery, New York (2022). https://doi.org/10.1145/3510003.3510038

  22. Phipps-Costin, L., Anderson, C.J., Greenberg, M., Guha, A.: Solver-based gradual type migration. Proc. ACM Program. Lang. 5(OOPSLA) (2021). https://doi.org/10.1145/3485488

  23. Pradel, M., Gousios, G., Liu, J., Chandra, S.: Typewriter: neural type prediction with search-based validation (2020)

    Google Scholar 

  24. Rastogi, A., Chaudhuri, A., Hosmer, B.: The ins and outs of gradual type inference. In: POPL 2012, pp. 481–494. ACM, New York (2012). https://doi.org/10.1145/2103656.2103714

  25. Rastogi, A., Swamy, N., Fournet, C., Bierman, G.M., Vekris, P.: Safe & efficient gradual typing for TypeScript. In: POPL (2015)

    Google Scholar 

  26. Siek, J.G., Vitousek, M.M., Cimini, M., Tobin-Hochstadt, S., Garcia, R.: Monotonic references for efficient gradual typing. In: Vitek, J. (ed.) ESOP 2015. LNCS, vol. 9032, pp. 432–456. Springer, Heidelberg (2015). https://doi.org/10.1007/978-3-662-46669-8_18

    Chapter  MATH  Google Scholar 

  27. Siek, J.G., Vachharajani, M.: Gradual typing with unification-based inference. In: Proceedings of the 2008 Symposium on Dynamic Languages, DLS 2008, pp. 7:1–7:12. ACM, New York (2008). https://doi.org/10.1145/1408681.1408688

  28. Siek, J.G., Vitousek, M.M., Cimini, M., Boyland, J.T.: Refined criteria for gradual typing. In: LIPIcs-Leibniz International Proceedings in Informatics, vol. 32. Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik (2015)

    Google Scholar 

  29. Takikawa, A., Feltey, D., Greenman, B., New, M.S., Vitek, J., Felleisen, M.: Is sound gradual typing dead? In: Proceedings of the 43rd Annual ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 2016, pp. 456–468. ACM, New York (2016). https://doi.org/10.1145/2837614.2837630

  30. Tobin-Hochstadt, S., Felleisen, M.: Interlanguage migration: from scripts to programs. In: Companion to the 21st ACM SIGPLAN Symposium on Object-Oriented Programming Systems, Languages, and Applications, OOPSLA 2006, pp. 964–974. ACM, New York (2006). https://doi.org/10.1145/1176617.1176755

  31. Tunnell Wilson, P., Greenman, B., Pombrio, J., Krishnamurthi, S.: The behavior of gradual types: a user study. In: Proceedings of the 14th ACM SIGPLAN International Symposium on Dynamic Languages, DLS 2018, pp. 1–12. Association for Computing Machinery, New York (2018). https://doi.org/10.1145/3276945.3276947

  32. Vitousek, M.M., Kent, A.M., Siek, J.G., Baker, J.: Design and evaluation of gradual typing for python. In: Proceedings of the 10th ACM Symposium on Dynamic Languages, DLS 2014, pp. 45–56. ACM, New York (2014). https://doi.org/10.1145/2661088.2661101

  33. Vitousek, M.M., Siek, J.G., Chaudhuri, A.: Optimizing and evaluating transient gradual typing. In: DLS 2019, pp. 28–41. ACM, New York (2019). https://doi.org/10.1145/3359619.3359742

  34. Vitousek, M.M., Swords, C., Siek, J.G.: Big types in little runtime: open-world soundness and collaborative blame for gradual type systems. In: Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages, POPL 2017, pp. 762–774. ACM, New York (2017). https://doi.org/10.1145/3009837.3009849

  35. Wadler, P., Findler, R.B.: Well-typed programs can’t be blamed. In: Castagna, G. (ed.) ESOP 2009. LNCS, vol. 5502, pp. 1–16. Springer, Heidelberg (2009). https://doi.org/10.1007/978-3-642-00590-9_1

    Chapter  MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Sheng Chen .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2024 The Author(s), under exclusive license to Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Khan, M.W., Chen, S. (2024). Gradual Typing Performance, Micro Configurations and Macro Perspectives. In: Chin, WN., Xu, Z. (eds) Theoretical Aspects of Software Engineering. TASE 2024. Lecture Notes in Computer Science, vol 14777. Springer, Cham. https://doi.org/10.1007/978-3-031-64626-3_15

Download citation

  • DOI: https://doi.org/10.1007/978-3-031-64626-3_15

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-031-64625-6

  • Online ISBN: 978-3-031-64626-3

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics