Skip to content

Instantly share code, notes, and snippets.

@hadley
Last active December 13, 2021 22:41
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hadley/6195660 to your computer and use it in GitHub Desktop.
Save hadley/6195660 to your computer and use it in GitHub Desktop.
A lighthearted and overly flattering comparison of R to other programming languages: what other comparisons have I missed?

R is like:

  • Clojure, because most objects are immutable
  • Scala, because it combined functional and OO techniques
  • Node.js, because the interpreter is single threaded
  • PHP, because it favours pragmatism over purity
  • Lisp, because it's homoiconic
  • Perl, because OO is (mostly) implemented using the language itself
@johnmyleswhite
Copy link

C because R encourages stateful programming?

@cscheid
Copy link

cscheid commented Aug 9, 2013

Can you say "because you can write programs that manipulate programs" instead of "because it's homoiconic"? R is at most as homoiconic as Python. They both have access to the AST, but homoiconicity means programs having the same representation as data. (Yes, it's a horribly abused term, but that's no reason to perpetuate the problem!)

(like Javascript because it has crazy scoping rules, but at least you can use closures :)

@crowding
Copy link

crowding commented Aug 9, 2013

@cscheid, R is homoiconic in your more narrow sense. You don't just "have access to" the AST, the AST and in-memory representation of programs is literally a tree of R objects. The R parser constructs a tree of data objects and the R evaluator merely steps over that tree. quote() is nearly a no-op, as it just returns its argument unevaluated.

@crowding
Copy link

crowding commented Aug 9, 2013

Like Haskell, because (some) evaluation is lazy
Like Kernel, because it has fexprs and first class environments and even the control flow forms are just functions
Like Ruby because embedded DSLs are easy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment