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

Actually, if you squint a lot, R (or S) is a functional language. And it shows, crazily powerful for something, absolutely horrible for something else.


No squinting needed :)

"R, at its heart, is a functional programming (FP) language. This means that it provides many tools for the creation and manipulation of functions. In particular, R has what’s known as first class functions. You can do anything with functions that you can do with vectors: you can assign them to variables, store them in lists, pass them as arguments to other functions, create them inside functions, and even return them as the result of a function."

http://adv-r.had.co.nz/Functional-programming.html


Yeah, lots of squinting needed, or a terribly shallow understanding of FP to say that. Merely providing first-class functions and map/reduce idioms does not a functional language make. Python has those, so is it also FP really? R is as much a FP language as Haskell or OCaml are imperative "at heart."


Sorry to STRONGLY disagree with you 100% but R clearly is a functional language and it might just be that you are unfamiliar with R or have not spent time with R.

Weak example is Wikipedia list of Functional Programming Languages list R as one. https://en.wikipedia.org/wiki/Functional_programming#R

R describes itself as a Functional programming Language:

The language syntax has a superficial similarity with C, but the semantics are of the FPL (functional programming language) variety with stronger affinities with Lisp and APL. In particular, it allows “computing on the language”, which in turn makes it possible to write functions that take expressions as input, something that is often useful for statistical modeling and graphics. https://cran.r-project.org/doc/manuals/r-release/R-lang.html

Academic Evidence: "The Journal Trends in Functional Programming" also list R as a functional programming language.

R is an environment and functional programming language for statistical data analysis and visualization. Largely unknown to the functional programming community, it is popular and influential in many empirical sciences.

http://link.springer.com/chapter/10.1007%2F978-3-642-40447-4...

The issue might be it isn't Haskel so it is not 100% functional but there are more Functional Programming Languages then Haskel.

PS This is why so many programs in R are poorly written because people try to force OO into R when they could do things Functional. That is also why my eyes bleed when I see people looping through everything in their R scripts.


Like many modern languages, R supports multiple programming paradigms, including sequential, object-oriented, and functional, but it should take more than a couple of functional features to declare something a full-blown FPL. A duck-billed platypus is not a duck.

Yes, you can write R code in a functional style in places when convenient, but one floor down it's still running that loop you didn't want to see. It's a language based on mutable values and sequential execution and looping, not pure function calls and recursion. The syntax itself is very much sequential, unlike stereotypical FPLs. Even the lexical scoping design relies fundamentally on mutable environments. So yes, people do seem to enjoy proudly declaring R a FPL citing a few features, but as I said, those features make R as much a FPL as Python.


> "terribly shallow understanding of FP to say that"

That was very condescending and I am sure don't know who Hadley Wickham is? I wouldn't call his understanding "Shallow."


No, I meant that he was squinting. What is condescending is you making assumptions about whom I don't know and what I'm unfamiliar with.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: