From: Igal Koshevoy Date: 2008-06-29T10:14:26+09:00 Subject: Re: Lambda calculus & functional programming - the view from Ruby Philip Rhoades wrote: > I have a general understanding of lambda calculus & functional > programming but I want to know how Ruby fits into this paradigm - is > there a summary doc somewhere (preferably with concrete examples) - I > couldn't find anything. What are the advantages/disadvantages, > strengths/weaknesses etc of the approach? I am gradually getting a > feel for "the Ruby way" and I thought this might help the process. I gave a presentation on this recently. Because Ruby is an object oriented language, it clashes philosophically with many things that functional programming holds dear. However, if one can live within these limitations, then there are ways to make effective use of the functional style in Ruby, such as chaining methods as if they were functions, which the Facets library (gem install facets) really helps with. The key lesson is that you want to go with what's most readable and easiest to maintain for you and your co-workers. In my examples, I progressively went further over the edge into less natural Ruby code, till the final examples looked so weird that you'd never realistically want to write code like that, although it's nice to know that we have the option. So some of this is useful, and some isn't. :) Code from my presentation: * http://www.pastie.org/224206 -- Functional one-liners with their imperative equivalents. * http://www.pastie.org/224228 -- Reimplementation of something like UNIX "du" in three different styles, with the FunctionalInPlace being generally agreed to as being too weird. -igal