Object-Oriented Programming, Functional Programming and R
Author:
- John M. ChambersJCJohn M. Chambers
Open Access
- 1 May 2014
- journal article
- Published by Institute of Mathematical Statistics in Statistical Science
- Vol. 29 (2) , 167-180
Abstract
This paper reviews some programming techniques in R that have proved useful, particularly for substantial projects. These include several versions of object-oriented programming, used in a large number of R packages. The review tries to clarify the origins and ideas behind the various versions, each of which is valuable in the appropriate context. R has also been strongly influenced by the ideas of functional programming and, in particular, by the desire to combine functional with object oriented programming. To clarify how this particular mix of ideas has turned out in the current R language and supporting software, the paper will first review the basic ideas behind object-oriented and functional programming, and then examine the evolution of R with these ideas providing context. Functional programming supports well-defined, defensible software giving reproducible results. Object-oriented programming is the mechanism par excellence for managing complexity while keeping things simple for the user. The two paradigms have been valuable in supporting major software for fitting models to data and numerous other statistical applications. The paradigms have been adopted, and adapted, distinctively in R. Functional programming motivates much of R but R does not enforce the paradigm. Object-oriented programming from a functional perspective differs from that used in non-functional languages, a distinction that needs to be emphasized to avoid confusion. R initially replicated the S language from Bell Labs, which in turn was strongly influenced by earlier program libraries. At each stage, new ideas have been added, but the previous software continues to show its influence in the design as well. Outlining the evolution will further clarify why we currently have this somewhat unusual combination of ideas.Keywords
All Related Versions
This publication has 8 references indexed in Scilit:
- Enhancing R with Advanced Compilation Tools and MethodsStatistical Science, 2014
- Rcpp: SeamlessRandC++IntegrationJournal of Statistical Software, 2011
- Software for Data Analysis2008
- Bioconductor: open software development for computational biology and bioinformaticsGenome Biology, 2004
- Programming with Data1998
- R: A Language for Data Analysis and GraphicsJournal of Computational and Graphical Statistics, 1996
- LISP‐STAT: An Object‐Oriented Environment for Statistical Computing and Dynamic Graphics1990
- A Method for Simulating Stable Random VariablesJournal of the American Statistical Association, 1976