Abstract
The R programming language has been lazy for over twenty-five years. This paper presents a review of the design and implementation of call-by-need in R, and a data-driven study of how generations of programmers have put laziness to use in their code. We analyze 16,707 packages and observe the creation of 270.9 B promises. Our data suggests that there is little supporting evidence to assert that programmers use laziness to avoid unnecessary computation or to operate over infinite data structures. For the most part R code appears to have been written without reliance on, and in many cases even knowledge of, delayed argument evaluation. The only significant exception is a small number of packages which leverage call-by-need for meta-programming.
Supplemental Material
- Lennart Augustsson. 1993. The Interactive Lazy ML System. J. Funct. Program. 3, 1. Google Scholar
Cross Ref
- John W. Backus and al. 1963. Revised Report on the Algorithm Language ALGOL 60. Commun. ACM 6, 1. Google Scholar
Digital Library
- Richard A. Becker, John M. Chambers, and Allan R. Wilks. 1988. The New S Language. Chapman & Hall.Google Scholar
- Martin Bodin, Tomás Diaz, and Éric Tanter. 2018. A trustworthy mechanized formalization of R. In Symposium on Dynamic Languages (DLS). Google Scholar
Digital Library
- Olivier Flückiger, Guido Chari, Jan Ječmen, Ming-Ho Yee, Jakob Hain, and Jan Vitek. 2019. R Melts Brains: An IR for First-Class Environments and Lazy Effectful Arguments. In Dynamic Language Symposium (DLS). Google Scholar
Digital Library
- Robert Gentleman, Vince J. Carey, and al. 2004. Bioconductor: open software development for computational biology and bioinformatics. Genome Biology 5. Google Scholar
Cross Ref
- Paul Hudak. 1989. Conception, Evolution, and Application of Functional Programming Languages. ACM Comput. Surv. 21, 3. Google Scholar
Digital Library
- Paul Hudak, John Hughes, Simon L. Peyton Jones, and Philip Wadler. 2007. A history of Haskell: being lazy with class. In History of Programming Languages Conference (HOPL-III). Google Scholar
Digital Library
- John Hughes. 1989. Why Functional Programming Matters. Comput. J. 32, 2. 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. http://www.amstat.org/publications/jcgs/Google Scholar
- Tomas Kalibera, Petr Maj, Floreal Morandat, and Jan Vitek. 2014. A Fast Abstract Syntax Tree Interpreter for R. In Conference on Virtual Execution Environments (VEE). Google Scholar
Digital Library
- Filip Křikava and Jan Vitek. 2018. Tests from traces: automated unit test extraction for R. In International Symposium on Software Testing and Analysis (ISSTA). Google Scholar
Digital Library
- 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). Google Scholar
Digital Library
- Hannes Mühleisen, Alexander Bertram, and Maarten-Jan Kallen. 2018. Database-Inspired Optimizations for Statistical Analysis. Journal of Statistical Software 87, 4. Google Scholar
Cross Ref
- Chris Okasaki. 1995. Simple and efficient purely functional queues and deques. Journal of Functional Programming 5, 4. Google Scholar
Cross Ref
- Shawn T. O’Neil. 2015. Implementing Persistent O(1) Stacks and Queues in R. The R Journal 7. Issue 1. Google Scholar
Cross Ref
- Kent M. Pitman. 1980. Special Forms in LISP. In LISP Conference. Google Scholar
Digital Library
- David Smith. 2011. The R Ecosystem. In The R User Conference 2011.Google Scholar
- Luke Tierney. 2019. A Byte Code Compiler for R. www.stat.uiowa.edu/~luke/R/compiler/compiler.pdfGoogle Scholar
- David A. Turner. 1979. A New Implementation Technique for Applicative Languages. Softw., Pract. Exper. 9, 1. Google Scholar
Cross Ref
- David A. Turner. 1985. Miranda: A Non-Strict Functional language with Polymorphic Types. In Functional Programming Languages and Computer Architecture (FPCA). Google Scholar
Cross Ref
- Mitchell Wand. 1998. The Theory of Fexprs is Trivial. Lisp and Symbolic Computation 10, 3. Google Scholar
Cross Ref
- Hadley Wickham. 2016. ggplot2: Elegant Graphics for Data Analysis. Springer-Verlag. http://ggplot2.orgGoogle Scholar
Digital Library
- Hadley Wickham. 2017. tidyverse: Easily Install and Load the ’Tidyverse’. https://CRAN.R-project.org/package=tidyverseGoogle Scholar
- Hadley Wickham, Romain Francois, Lionel Henry, and Kirill Müller. 2018. dplyr: A Grammar of Data Manipulation. https://CRAN.R-project.org/package=dplyrGoogle Scholar
- Andrew K. Wright and Matthias Felleisen. 1992. A Syntactic Approach to Type Soundness. Information and Computation 115. Google Scholar
Digital Library
Index Terms
On the design, implementation, and use of laziness in R
Recommendations
Promises are made to be broken: migrating R to strict semantics
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 ...
Complete Laziness: a Natural Semantics
Lazy evaluation (or call-by-need) is widely used and well understood, partly thanks to a clear operational semantics given by Launchbury. However, modern non-strict functional languages do not use plain call-by-need evaluation: they also use ...
Laziness by need
ESOP'13: Proceedings of the 22nd European conference on Programming Languages and SystemsLazy functional programming has many benefits that strict functional languages can simulate via lazy data constructors. In recognition, ML, Scheme, and other strict functional languages have supported lazy stream programming with delaytt and forcett for ...






Comments