Hacker News new | ask | show | jobs
by clircle 1164 days ago
Whoa, you know this is hacker news right? You don't get to call R elegant around these parts.
3 comments

R isn't elegant, but tidyverse is

If you learn tidyverse, then you're going to cringe whenever you use Pandas or most things in the Python data science ecosystem

https://www.rstudio.com/wp-content/uploads/2015/02/data-wran...

Oh, I do cringe at Pandas.
I think R is elegant, what's inelegant in it (other than the code lots of non-programmers write with it)?
Core language design? Definitely elegant in my opinion. F-expressions, clever "formula" syntax, everything is an array, great C/C++/Fortran interop.

Standard library? Absolute chaos. Some elegant subsets, but mostly a mess that you learn to live with.

It has 4 ways to do object orientation if IIRC, none of which are compatible.
S3, S4, R6, and reference classes. To be fair they are situational and not one size fits all. The stricter ones are mainly used in biostats where significant metadata makes more sense in OO. S3 is nice and easy, primarily just a list with dispatches. Everything else is less so.
The type system is so abhorrent, it makes me wonder if it's actually proper to call R a real programming language
"There are only two kinds of languages: the ones people complain about and the ones nobody uses."
This crappy quote is always used to justify bad design.
I'm sorry, did you mean

    [1] "There are only two kinds of languages: the ones people complain about and the ones nobody uses."
:^)
And from a different point of view, real programming languages have built-in vectorization and 1-based arrays ;)
what specifically is abhorrent about it?
The coercion always gets on my nerves, JavaScript gets a bad rep but R is pretty damn warty too; weird ass data types ('ordered factor', anyone) that just seem so very far away from design choices in other languages without being particularly ergonomic or aesthetically appealing
The data types make sense to statisticians. Ordered factors are great when you need to fit, say, an ordered logit regression model.
Which coercion specifically are you talking about? Could you give an example?

Weird data types: R had been designed for and by statisticians with their specific needs in mind, which indeed could look weird to regular people.

I remember when we first used R in a stochastic class. The professor (a mathematician) was in love with the language and the students (computer science) considered the language to be the PHP of science.
as a computer scientist and programming languages nerd, I think R is a much better language than Python (comparing the two only because Python is leading in the data science field)

I also believe that the tools available are superior, RStudio is very good IMO.

I wonder why R has such a bad reputation.

Because it’s built around a very specialized set of needs (data manipulation, visualization, and statistical modeling), and it is essentially best in class at it, but it has quirks as a result. Anyone coming to R from a background in another language will feel those quirks intensely and assume it’s bad.
A lot of programmers dislike R for the same reason they dislike PHP: weak typing.

If you can get over that, though, there's a lot to like about R. It's sort of like a hybrid between a Lisp and an array language.

Javascript and C also have weak typing. And Python isn't statically typed, it's just that like Ruby, it doesn't allow implicit conversion, except with numbers.
Weak typing? No, it's not. R is a strongly typed language.

> 1 + "string"

Error in 1 + "str" : non-numeric argument to binary operator

Iirc the scoping is also very strange. Certainly not as bad as mathematica, but bad nonetheless.