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.
Supplemental Material
- 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 Scholar
Cross Ref
- Richard A. Becker, John M. Chambers, and Allan R. Wilks. 1988. The New S Language. Chapman & Hall.Google Scholar
- Stephen Chang and Matthias Felleisen. 2014. Profiling for Laziness. 49, 1 (2014), https://doi.org/10.1145/2578855.2535887 Google Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
- 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 Scholar
Cross Ref
- Uwe Ligges. 2017. 20 Years of CRAN (Video on Channel9). In UseR! Conference.Google Scholar
- 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 Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- Allen Wirfs-Brock and Brendan Eich. 2020. JavaScript: The First 20 Years. 4, HOPL (2020), https://doi.org/10.1145/3386327 Google Scholar
Digital Library
- 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 Scholar
Digital Library
Index Terms
Promises are made to be broken: migrating R to strict semantics
Recommendations
A fast abstract syntax tree interpreter for R
VEE '14Dynamic languages have been gaining popularity to the point that their performance is starting to matter. The effort required to develop a production-quality, high-performance runtime is, however, staggering and the expertise required to do so is often ...
A fast abstract syntax tree interpreter for R
VEE '14: Proceedings of the 10th ACM SIGPLAN/SIGOPS international conference on Virtual execution environmentsDynamic languages have been gaining popularity to the point that their performance is starting to matter. The effort required to develop a production-quality, high-performance runtime is, however, staggering and the expertise required to do so is often ...
Optimizing R language execution via aggressive speculation
DLS '16The R language, from the point of view of language design and implementation, is a unique combination of various programming language concepts. It has functional characteristics like lazy evaluation of arguments, but also allows expressions to have ...






Comments