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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
\(2\times 2\times 3=12\), but we need to minus one combination whose all components are static.
- 2.
References
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
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)
Campora, J.P., Chen, S.: Taming type annotations in gradual typing. Proc. ACM Program. Lang. 4(OOPSLA) (2020). https://doi.org/10.1145/3428259
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
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
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
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
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
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
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
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
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
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
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
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
Migeed, Z., Palsberg, J.: What is decidable about gradual types? Proc. ACM Program. Lang. 4(POPL) (2019). https://doi.org/10.1145/3371097
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)
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
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
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
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
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
Pradel, M., Gousios, G., Liu, J., Chandra, S.: Typewriter: neural type prediction with search-based validation (2020)
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
Rastogi, A., Swamy, N., Fournet, C., Bierman, G.M., Vekris, P.: Safe & efficient gradual typing for TypeScript. In: POPL (2015)
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
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
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)
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
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
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
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
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
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
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
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2024 The Author(s), under exclusive license to Springer Nature Switzerland AG
About this paper
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)