4 ms·
The terrible naming is an annoyance, but the ridiculous number of data structures isn't as bad as R's tendency to jump between them in a semi-random manner. My
by roenxi 8y ago
The terrible naming is an annoyance, but the ridiculous number of data structures isn't as bad as R's tendency to jump between them in a semi-random manner.
My example is if A is a matrix and b/c are variables then you don't know what the data type of A[b,c] is. I can tell you the types of A, b, c and that doesn't help; you need to know about the actual data stored in the variables to know if the return value is still a matrix or if R has thrown out the dimension information and jumped back to a vector (potentially transposing the result). You have to know about the drop=FALSE option and at that point the syntax of doing a complicated equation involving recursion and matrices falls apart.
The syntax is an embarrassment for working with matricies. I'd rather use a lisp-style (-> A (mmul v) (subset 1 k 1 j)), which isn't ideal but at least it doesn't have random options being set in the middle of it.
That single decision should be enough to disqualify R from being a well designed language for mathematical applications. The pigs breakfast that is the *apply() function family is a similar story.
The distinction between vectors, matricies, lists-of-lists and data frames is archaic too, the conceptual model should be a single 2-d data structure and then support additional operations under certain conditions. At least that particular decision makes sense at the time R was designed.
- kestreloats 8y agoSo... I've been programming in R for over 20 years. I've been ready for an alternative for performance reasons for about half that time. Julia seems like a promising alternative, that I wish I could use all the time instead of R but it's just not there; I'd prefer Nim most of all but that's even less well-resourced in terms of libraries. Maybe a zero-cost abstracted offshoot of Rust will eventually come to have a role? Who knows. R, like Python, has far outgrown its initial scope. I don't think it was initially envisioned to be used the way it is today. But both have been kept in use as costumes for C/C++. One of the things I've noticed the most in the last 20 years, to your point, is that the language used to be a lot more straightforward and simpler, more predictable. Over the years a lot has been added in a sort of haphazard way, and as a result today you have this kind of Frankenstein language that isn't what it started with. As for data structures, though, I don't really see R as being that different from other languages. Many of them are the same as in other languages, but just have different names (and I do wish they used similar terminology). Others have been taken up in other languages as people have come to appreciate their utility. Being a wrapper for C/C++ can only go so far. Eventually you have to write in R (or Python) and the speed shows, if you have enough data to deal with.