I've always found Ruby to be an amazing mix of functional & OOP already, what with blocks, and that class definitions are also (actually?) functions themselves. And don't forget being able to drop parens!
I've also always felt like Ruby had mostly clear vision - arguably better than a perfectly clear one, since it leaves more room for play, exploration, and other people's contribution - even if it's not one that's able to be put into words. Every time I came across something surprising in Ruby, once I learned what was going on, it made sense in that larger whole.
So basically Ruby is far from FP. It sticks to OOP, which has actually been proven to work.
No mainstream FP language is doing pure lambda calculus.
that's what a lambda is pretty much anywhere, FP or not :)
> [in FP] you're supposed to be doing absolutely everything with lambdas even addition
in imperative programming, are you supposed to be doing everything by writing symbols to a moving tape, a la Turing? there's more to FP than pure lambda calculus, even if it was the starting point.
sure, natural numbers and other types can be implemented with lambdas. no serious FP language actually does that.
What features?
Smalltalk-80 already had lambdas and LINQ, they were just called blocks and collection methods instead.
Pattern matching in OOP languages was a path pursued by BETA, Simula's successor by the same authors, where even classes are instances of patterns as concept.
Chapter 3, Objects and Patterns
Oberon-2 type guards, which are basic but still have the same idea somehow, https://cseweb.ucsd.edu/~wgg/CSE131B/oberon2.htm
Modula-3 type case, https://www.cs.purdue.edu/homes/hosking/m3/reference/typecas...
Luckily this new pattern matching feature appears to behave like expected and feels pretty natural - just a new `in` keyword and some variable binding syntax to familiarize ourselves with (which we already kind of use with statements like `rescue`).
Awhile back we experimented with an alternative Ruby pipe operator proof of concept[2] that is "operator-less" and looks just like regular old Ruby blocks with method calls inside of it. Maybe there's still a chance for something like this now that those other implementations have been reverted!
# regular inverted method calls
JSON.parse(Net::HTTP.get(URI.parse(url)))
# could be written left to right
url.pipe { URI.parse; Net::HTTP.get; JSON.parse }
# or top to bottom for even more clarity
url.pipe do
URI.parse
Net::HTTP.get
JSON.parse
end
[0] Revert pipeline operator: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/...[1] Revert method reference operator: https://bugs.ruby-lang.org/issues/16275
[2] Experimental "operator-less" Ruby pipe operator proof of concept: https://github.com/lendinghome/pipe_operator
ADTs don't exist in OOP. It gets more complicated to do matches against classes whose abstractions are not really decomposable so easily.
Now technically yes all FP idioms are just simple operations below that can be used. And they are.. python, js have destructuring which is a first stage pattern matching.
Today, "open" extensibility mechanisms are considered a bit problematic because it's never really clear what invariants they should preserve, so maintaining correctness is an issue. A "closed" interface makes it essier to specify related invariants.
Rubycop’s author criticized[0] Ruby 2.7 for losing a direction/vision where Ruby should go (which sparked controversial operators that were quickly removed).
Most of them looks like, at least to me, trying to fit a functional programming features in an inherently object-oriented language to be ‘hip’. Like... the pipeline operator which had strange semantics.
I hope this isn’t one.
[0] Ruby, Where do We Go Now?: https://metaredux.com/posts/2019/12/06/ruby-where-do-we-go-n...