skip to main content

Promises are made to be broken: migrating R to strict semantics

Published:15 October 2021Publication History
Skip Abstract Section

Abstract

Function calls in the R language do not evaluate their arguments, these are passed to the callee as suspended computations and evaluated if needed. After 25 years of experience with the language, there are very few cases where programmers leverage delayed evaluation intentionally and laziness comes at a price in performance and complexity. This paper explores how to evolve the semantics of a lazy language towards strictness-by-default and laziness-on-demand. To provide a migration path, it is necessary to provide tooling for developers to migrate libraries without introducing errors. This paper reports on a dynamic analysis that infers strictness signatures for functions to capture both intentional and accidental laziness. Over 99% of the inferred signatures were correct when tested against clients of the libraries.

Skip Supplemental Material Section

Supplemental Material

Auxiliary Presentation Video

This is a presentation video of my talk at OOPSLA 2021 on our paper - Promises Are Made to Be Broken. Function calls in the R language do not evaluate their arguments, these are passed to the callee as suspended computations and evaluated if needed. After 25 years of experience with the language, there are very few cases where programmers leverage delayed evaluation intentionally and laziness comes at a price in performance and complexity. This paper explores how to evolve the semantics of a lazy language towards strictness-by-default and laziness-on-demand. To provide a migration path, it is necessary to provide tooling for developers to migrate libraries without introducing errors. This paper reports on a dynamic analysis that infers strictness signatures for functions to capture both intentional and accidental laziness. Over 99% of the inferred signatures were correct when tested against clients of the libraries.

References

  1. Karan Aggarwal, Mohammad Salameh, and A. Hindle. 2015. Using machine translation for converting Python 2 to Python 3 code. PeerJ Prepr., 3 (2015), https://doi.org/10.7287/PEERJ.PREPRINTS.1459V1 Google ScholarGoogle ScholarCross RefCross Ref
  2. Richard A. Becker, John M. Chambers, and Allan R. Wilks. 1988. The New S Language. Chapman & Hall.Google ScholarGoogle Scholar
  3. Stephen Chang and Matthias Felleisen. 2014. Profiling for Laziness. 49, 1 (2014), https://doi.org/10.1145/2578855.2535887 Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. B. Collie, P. Ginsbach, J. Woodruff, A. Rajan, and M. F. P. O’Boyle. 2020. M3: Semantic API Migrations. In Conference on Automated Software Engineering (ASE). https://doi.org/10.1145/3324884.3416618 Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Robert Ennals and Simon Peyton Jones. 2003. Optimistic Evaluation: An Adaptive Evaluation Strategy for Non-Strict Programs. ICFP ’03, 38, 9 (2003), https://doi.org/10.1145/944746.944731 Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Mattia Fazzini, Qi Xin, and Alessandro Orso. 2020. APIMigrator: An API-Usage Migration Tool for Android Apps. In International Conference on Mobile Software Engineering and Systems (MobileSoft). https://doi.org/10.1145/3387905.3388608 Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Olivier Flückiger, Guido Chari, Jan Jecmen, Ming-Ho Yee, Jakob Hain, and Jan Vitek. 2019. R melts brains: an IR for first-class environments and lazy effectful arguments. In International Symposium on Dynamic Languages (DLS). https://doi.org/10.1145/3359619.3359744 Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Olivier Flückiger, Guido Chari, Ming-Ho Yee, Jan Jecmen, Jakob Hain, and Jan Vitek. 2020. Contextual Dispatch for Function Specialization. Proc. ACM Program. Lang., 4, OOPSLA (2020), https://doi.org/10.1145/3428288 Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Aviral Goel and Jan Vitek. 2019. On the design, implementation, and use of laziness in R. Proc. ACM Program. Lang., 3, OOPSLA (2019), https://doi.org/10.1145/3360579 Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Ross Ihaka and Robert Gentleman. 1996. R: A Language for Data Analysis and Graphics. Journal of Computational and Graphical Statistics, 5, 3 (1996), http://www.amstat.org/publications/jcgs/Google ScholarGoogle Scholar
  11. Simon Peyton Jones and Will Partain. 1993. Measuring the effectiveness of a simple strictness analyser. In Proceedings of the 1993 Glasgow Workshop on Functional Programming (Workshops in Computing). https://doi.org/10.1007/978-1-4471-3236-3_17 Google ScholarGoogle ScholarCross RefCross Ref
  12. Uwe Ligges. 2017. 20 Years of CRAN (Video on Channel9). In UseR! Conference.Google ScholarGoogle Scholar
  13. Floréal Morandat, Brandon Hill, Leo Osvald, and Jan Vitek. 2012. Evaluating the Design of the R Language: Objects and Functions for Data Analysis. In European Conference on Object-Oriented Programming (ECOOP). https://doi.org/10.1007/978-3-642-31057-7_6 Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Chris Okasaki. 1995. Simple and efficient purely functional queues and deques. Journal of Functional Programming, 5, 4 (1995), https://doi.org/10.1017/S0956796800001489 Google ScholarGoogle ScholarCross RefCross Ref
  15. Simon L. Peyton Jones and André L. M. Santos. 1998. A Transformation-Based Optimiser for Haskell. Sci. Comput. Program., 32, 1–3 (1998), https://doi.org/10.1016/S0167-6423(97)00029-4 Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Michael Pradel, Georgios Gousios, Jason Liu, and Satish Chandra. 2020. TypeWriter: Neural Type Prediction with Search-Based Validation. https://doi.org/10.1145/3368089.3409715 Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Lukas Stadler, Adam Welc, Christian Humer, and Mick Jordan. 2016. Optimizing R language execution via aggressive speculation. In Symposium on Dynamic Languages (DLS). https://doi.org/10.1145/2989225.2989236 Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Sam Tobin-Hochstadt and Matthias Felleisen. 2006. Interlanguage Migration: From Scripts to Programs. In Companion to the Symposium on Object-Oriented Programming Systems, Languages, and Applications. https://doi.org/10.1145/1176617.1176755 Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Alexi Turcotte, Aviral Goel, Filip Krikava, and Jan Vitek. 2020. Designing Types for R, Empirically. Proc. ACM Program. Lang., 4, OOPSLA (2020), https://doi.org/10.1145/3428249 Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. Yisu Remy Wang, Diogenes Nunez, and Kathleen Fisher. 2016. Autobahn: Using Genetic Algorithms to Infer Strictness Annotations. SIGPLAN Not., 51, 12 (2016), https://doi.org/10.1145/3241625.2976009 Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. Allen Wirfs-Brock and Brendan Eich. 2020. JavaScript: The First 20 Years. 4, HOPL (2020), https://doi.org/10.1145/3386327 Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. S. Xu, Z. Dong, and N. Meng. 2019. Meditor: Inference and Application of API Migration Edits. In International Conference on Program Comprehension (ICPC). https://doi.org/10.1109/ICPC.2019.00052 Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Promises are made to be broken: migrating R to strict semantics

          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

          • Article Metrics

            • Downloads (Last 12 months)100
            • Downloads (Last 6 weeks)3

            Other Metrics

          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!