What is the programming paradigm of R?

user438602 picture user438602 · May 23, 2011 · Viewed 7.1k times · Source

What is the programming paradigm of R (R as in GNU S)?

I believe myself familiar with programming languages of different conceptual paradigms (have programmend in C++, Java, Prolog and some other languages) but although I already write my own small R scripts, I am not sure which paradigm R is supposed to represent.

Answer

hadley picture hadley · May 25, 2011

R supports a mixture of object-oriented and functional programming paradigms.

On the functional side it:

  • has first class functions
  • has lazy evaluation of arguments
  • encourages pure, side-effect free functions

But

  • it does not implement tail call recursion
  • and it's easy to create non-pure functions

On the object oriented side:

  • it has three built in OO paradigms: S3 and S4, which are immutable and support generic function style OO, and reference classes (aka R5) which are mutable, and support the more common message-passing style OO.

  • S4 is heavily influenced by the OO-style of common lisp (CLOS) and dylan.

  • There are also a number of contributed packages that provide other types of OO: proto, mutatr, R.oo, OOP.

But

  • The built-in OO tools provide little in the way of syntactic sugar.