3 ms·
Hmmm. I'm definitely in favor of more functional programming features / capabilities, particularly in a language like Ruby that allows for pretty effective mixi
by RangerScience 7y ago
Hmmm. I'm definitely in favor of more functional programming features / capabilities, particularly in a language like Ruby that allows for pretty effective mixing of OOP/functional paradigms. Right tool for the job, where the job is usually "communicating with other programmers what this code should do".
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.
- zelly 7y agoRuby blocks are another example of something that looks like a functional programming feature but is actually not. As in Java 8 and C++11, which also added lambdas, it doesn't have much in common with FP lambdas. These are essentially syntax sugar for an ad-hoc function that's too small to factor our and give a name. FP lambdas are the most elementary unit of computation. You're supposed to be doing absolutely everything with lambdas even addition, theoretically (head in the clouds academic BS), and the other syntax (like `do` in Haskell) is sugar for lambdas. So basically Ruby is far from FP. It sticks to OOP, which has actually been proven to work.
- pjmlp 7y agoFrom CS point of view, I miss the point you are trying to make. No mainstream FP language is doing pure lambda calculus.
- foldr 7y agoIIRC the main distinguishing feature of ruby blocks from regular anonymous functions is that you can break out of a containing scope from within them.
- uryga 7y ago> [Java 8 and C++11 lambdas] are essentially syntax sugar for an ad-hoc function 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.