And R excels at doing statistics and data science. If you keep that mindset, I believe many will find that its an excellent programming language.
We were essentially told "Install R Studio, then just copy and paste these library imports and you're good to go". Your description of a vectorized language makes total sense, and that single paragraph is more of an intro to R than we ever got in class.
That said, I think the reason this happened with this class in particular is the viewpoint of (what I perceive) as the majority user's of R. Mathematics focused researchers who never learned the language, they just have done enough to get by and don't really appreciate the underpinnings, or the nuances of running an environment on a machine that isn't theres.
I can't entirely absolve myself of blame though, once I realized what was happening I should have gone and done some more foundational R learning, but at that point I just wanted to be done with the class.
But for "the majority of professors who tangentially use R code in classes on statistics/bioinformatics/economics/finance (anything not explicitly about R and/or Data Science best practices)"? Absolutely.
The R code you see in industry (or academic labs where someone cares about modern R) looks vastly different from those script examples in college that are most people's first impression of the language.
Haskell is an advanced functional programming language. Most R stuff seems to be incoherent, hard to verify correctness, hacky. It does not seem built on a solid foundation like Haskell. Truly everything being a vector is not a huge take away.
As for "here's just a bunch of examples", well that seems sort of a brute force way to learn something. I agree examples are important, but they are usually to back something up. Having to reverse engineer some fundamental ideas out of just examples is more work. Seems like this is just promoting more hackyness. Seems like its training a neural network instead of actually understanding something.
* Multiple dispatch. Before learning R, I knew about polymorphism in Java and C++, and multiple dispatch in R broadened my mind and turns out to be very handy.
* The idea of "frames". In R, when you invoke `lm(height~sex*age, data=mydataframe)`, the first argument (the formula) doesn't get evaluated until the lm command asks it to be evaluated, and lm can set up the "frame" for that evaluation, i.e. the place where variables are looked up, however it likes. In fact, lm sets it up to include variables from both the scope in which you invoked lm, and also from mydataframe. This is what makes R so wonderfully concise for modelling in data science, compared to e.g. Python + pandas. I knew about frames from interactive debuggers, but until R it never occurred to me that the programming language could manipulate them.
* "Held" arguments. In R, when you invoke `plot(x, y1+y2)`, it doesn't just evaluate the arguments and then call the plot function -- it leaves the arguments unevaluated, and invokes plot. Plot then (1) decides when to evaluate them, (2) gets access to the language expression `y1+y2`, which means that it can print "y1+y2" on the plot label, (3) it can even define extra variables to include in the scope when y1+y2 gets evaluated. (I knew about held arguments earlier, from Mathematica, but they only clicked when I read the R documentation.)
I've read that R is a descendent of Scheme, and that that's where it gets all its "manipulate language expressions" from. I don't know any Scheme, nor Lisp, and I should definitely learn them -- but in the meantime, my experience has been that R's ability to manipulate language expressions is what makes it such a wonderful sweet spot as a data modelling language. I mostly use Python + pandas nowadays, but it feels such a slog in comparison.
A. Understanding how to implement functions using syntactic forms is a steep learning curve. I remember running out of dplyr and having to implement a udf. Fairly unpleasant experience (enquo, !!, perhaps other unusual constructs). Felt like programming C macros.
B. "A function can decide where variables are looked up however it likes" is a significant obstacle in understanding how even basic constructs like function calls actually work. There is a non-trivial amount of hard-to-debug dark magic lurking behind every corner.
A middle ground has never been achieved. For example, `plot(expr(x), expr(y1 + y2))`, where the system limits the dark magic to explicit uses of the `expr()` construct, and `expr(x)` always means `{vars: vars(x), expr: (vars(x)) => x}`. Instead of patching interpreter environments, simply call a lambda function.
That's the weird thing about R. All this dark magic is hiding under the hood, but the core R team hid it so deftly that to the casual statistician it's a straightforward data modelling language that "just works". I'm not sure that it's possible to get rid of the dark magic and retain that data-modeller friendliness.
If you define a language that "will expand your programming views" as one that can verify correctness easily then yeah, R is terrible at that. But so are many languages that are as flexible as R. Would you have the same opinion of FORTH? Or LISP? or TCL? I think these languages definitely count as "hacky" languages and yet they don't seem to draw the same derision as R (in my experience)
The same could technically be argued for Python; The current approaches to dealing with high-performance compute workloads either rely on JITing (e.g. Numba, Tensorflow/JAX's XLA) or bridging over to giant binary blobs through the CPython's well-supported C interop.
If you want to see the performance benchmark of R against major programming languages for data analysis please check this excellent keynote speech on the R compilation or more accurately on failures of R compilation effort [2].
As mentioned in [1], the main reason people do not focus on providing industrial strength compiler for R is probably because most of R program’s time are spent in the library codes that are written in a compiled language (e.g., C or Fortran). As you can see from [2], even though this is the case (computation intensive being delegated to proper compiled languages), the R programs running time still suffers due to the "impedance mismatch" because of the look up overheads, indirections, etc.
Perhaps someone should try to compile, transpile and/or embed R inside D language similar to the efforts provided in [3][4]. D now supports C compiler internally, has DasBetterC and D interface to C++ (DPP) is second to none. Additionally, since D can also perform better than Fortran codes for numerical computing perhaps Fortran codes can eventually be replaced by existing high performance D library like Mir[5]. I can foresee this symbiotic relationship can be beneficial for R and D (R on D?). D can becomes very popular with extra humongous data analysis and statistics libraries from CRAN, and R can get the run time and compilation performance improvement it badly needs.
[1]https://www.r-bloggers.com/2021/05/where-are-the-industrial-...
[2]https://www.youtube.com/watch?v=VdD0nHbcyk4
[3]https://dlang.org/blog/2018/06/20/how-an-engineering-company...
[4]https://theartofmachinery.com/2021/01/01/djinn.html
[5]http://blog.mir.dlang.io/glas/benchmark/openblas/2016/09/23/...
[0] There's an old article from Robert Gentleman named something like "S4 objects in 5 pages, more or less" but I can't find it. However, there's a mention of Dylan and CLOS here: https://genomebiology.biomedcentral.com/articles/10.1186/gb-...
EDIT: Here's the document I was looking to cite: https://www.stat.auckland.ac.nz/S-Workshop/Gentleman/S4Objec...
https://arxiv.org/pdf/1409.3531.pdf
Object-Oriented Programming, Functional Programming and R (John M. Chambers)
"Chambers and Hastie (1992), in the discussion of classes and methods, noted that S differed from other OOP languages because of its functional programming style. In fact, this version of functional OOP finessed the resulting distinction from encapsulated OOP in two ways. First, the methods were dispatched according to a single argument, the first formal argument of the generic function in principle. As a result, the methods were unambiguously associated with a single class, as they would be in encapsulated OOP. Methods were actually dispatched on either argument to the usual binary operators, but a number of encapsulated OOP languages do the same, under the euphemism of operator overloading.
"Second, the question of whether methods belonged to a class or a function was avoided by not having them belong to either. Methods were assigned as ordinary functions and identified by the pattern of their name: “function.class”. In any case, there were no class objects and generic functions were ordinary functions that invoked UseMethod() to select and call the appropriate method. Neither the function nor the class was able to own the methods."
S3 appeared a few years before Java but there were other OOP languages like C++ around at the time.
It’s not just vectorizing mathematical operations a la numpy.
Certainly R has its quirks, but most of this comes from being one of the oldest continuing existing programming languages there is. It derives from S which was written 46 years ago. Because of this it has multiple object/class systems reflecting the changing standards for OOP. It's most dominant one, S3, predates Java and therefore uses the Generic Function paradigm of OOP similar to Common Lisp's ClOS. If you're experienced but have never worked with non-Java style OOP you're going to be a bit confused.
R's most important feature, which is well worth studying and mastering for any serious programmer, is that it is a completely vectorized programming language. It borrows this style from APL (though is a million times more readable). Every value in R is a vector and for the vast majority of operations the best approach to solve your problem is by thinking in vector operations. This makes simple things like string formatting with `paste` seem like a confusing nightmare, but there is a real logic there. Functions like `ifelse` can seem strange, and writing C-style code in R, while possible will result in horrible performance.
Once you do learn to think in vectors you realize that R isn't just popular in the stats world because most statisticians haven't seen a "real" programming language, but because you can very rapidly iterate on models. Translating mathematical notation into R, for the experience R programmer, is easier than any other language I've worked with by a long shot.
My advice to any experienced programmer approaching R is to have some respect for the language. Most of the frustrations you'll have aren't because R is a bad language, but because you have less experience than you think and learning R well can expand your programming views in a similar way to Haskell.