Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

One really underappreciated aspect of R is that it's a lisp at heart. This enables the user (and enterprising package writer) to build really clean abstractions for the task at hand.

The tidyverse suite of Hadley Wickham is a great example of this, notably with the pipe operator %>% (similar to |> in F#) which is not part of the base language and yet could be very easily implemented. Julia's macros probably enables the same type of implementation, but I don't see how one would achieve it as easily in Python for example. Non-standard evaluation is another example of R's lispiness in action [0].

Also, consider how easy it is to walk R's S-exp. Expressions in R can only be one of four things: an atomic value, a name, a call or a pairlist. Wickham's Advanced R has a great intro on this [1].

I believe Wickham's amazing work with tidyverse (which really changes the way you code in R) is just the beginning of a rediscovery of R's inner lisp power, a kind of "R: the good parts" moment.

[0] http://adv-r.had.co.nz/Computing-on-the-language.html

[1] http://adv-r.had.co.nz/Expressions.html



Anyone with a programming background getting into R should absolutely go read _Advanced R_. I've been using R off and on for a while now but Advanced R was a real revelation. All of R's weird behavior finally made sense.

Edit: Also there is a 2nd edition in the works: (confusingly hosted at the same subdomain of a different version of Hadley Wickham's website. https://adv-r.hadley.nz/


The subdomain confusion will get resolved once the 2nd ed is a bit more mature so I can just redirect the 1st ed.


After reading Advance R I HIGHLY recommend learning Racket (a lisp) and work through "How to Design Programs" it will take a while and it is very dense but this is the best thing I have ever did to make my programming skills better.

http://www.ccis.northeastern.edu/home/matthias/HtDP2e/index....


Looks nice! Thanks!


Python is very hackable. Some time ago I answered a couple questions about how to implement a "pipe" operator in Python at stackoverflow:

* “Piping” output from one function to another using Python infix syntax[1]

* How can I create a chain pipeline?

Often in Python it is not a matter of it being possible/impossible (to implement a different syntax), it has more to do with being always ultra-idiomatic. The zen of Python says "Special cases aren't special enough to break the rules" and the community tends to avoid writing a DSL like the plague.

[1] https://stackoverflow.com/questions/33658355/piping-output-f...

[2] https://stackoverflow.com/questions/47474704/how-can-i-creat...


FYI, the pipe operator for R (and other languages that have it built in) are for calling any functions with any parameter types. This is not just academic, in the tidyverse style it's both common and idiomatic to change object types in the middle of a pipeline (for example, from a data frame to a vector, or from JSON to data frame to an interactive Leaflet map).

While Python decorators and operators can get you surprisingly far, I just don't see them being in the same league as languages like Lisp and R that let you manipulate the AST really easily.

Agreed though that the culture of Python is the exact opposite of R (and Ruby, Perl, Lisp), and even if Python had all the same metaprogramming goodies as R you wouldn't see as widespread use.


Best thing I ever learned about R was it's scheme influence. I ended up learning Racket and it changed everything I have ever coded in R. Actually I have made Racket my main general purpose language of choice after going through "How to Design Programs."


Ros Ihaka actually suggested rewriting R in Common Lisp.

https://www.stat.auckland.ac.nz/~ihaka/downloads/Compstat-20...


It's not just Lisp, it's an fexpr Lisp. Pretty cool (but also kind of maddening).

See also, this dead but fascinating project: https://github.com/crowding/vadr




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: