1 Mar 2007 01:04
Re: Functional programming in Ruby
Chad Perrin <perrin <at> apotheon.com>
2007-03-01 00:04:32 GMT
2007-03-01 00:04:32 GMT
On Thu, Mar 01, 2007 at 07:20:28AM +0900, Brian Candler wrote: > Not a question or anything... I just wanted to share this snippet with > any non-computer-scientist who thinks this is cool(Continue reading)> > I come from very much an imperative programming background - originally > machine code. Computer science books tend to use LISP, and I find anything > other than the simplest example to be impenetrable. However, translating > them to Ruby makes it much clearer to me what's going on. If you want to play with a more "functional" language than Ruby, you might try ML (or OCaml), Haskell, or UCBLogo. The first of these is pretty accessible to someone coming from an imperative and OOP background because it is not *just* a functional language -- it also provides integral OOP and imperative constructs. The second can be pretty impenetrable to someone not already familiar with functional programming, but it is about as "pure" an FP language as you're likely to find. UCBLogo is like readable Lisp (complete with macros), and there's a trilogy of college programming and CompSci textbooks available for free online for it. Roughly open source implementations of all three languages are available (I say "roughly" because the OCaml license only allows you to distribute alterations to the "official" codebase via patches). Of course, Ruby's good for learning functional programming concepts, up to a point, too. I, for one, am using Ruby more for enhancing my OOP skills. I'll be using the other three languages I mentioned for my further FP investigations, I'm sure. Of the two, I've already started playing with OCaml and UCBLogo over the course of the last year, and found a lot to like about both.
>
> I come from very much an imperative programming background - originally
> machine code. Computer science books tend to use LISP, and I find anything
> other than the simplest example to be impenetrable. However, translating
> them to Ruby makes it much clearer to me what's going on.
If you want to play with a more "functional" language than Ruby, you
might try ML (or OCaml), Haskell, or UCBLogo. The first of these is
pretty accessible to someone coming from an imperative and OOP
background because it is not *just* a functional language -- it also
provides integral OOP and imperative constructs. The second can be
pretty impenetrable to someone not already familiar with functional
programming, but it is about as "pure" an FP language as you're likely
to find. UCBLogo is like readable Lisp (complete with macros), and
there's a trilogy of college programming and CompSci textbooks available
for free online for it. Roughly open source implementations of all
three languages are available (I say "roughly" because the OCaml license
only allows you to distribute alterations to the "official" codebase via
patches).
Of course, Ruby's good for learning functional programming concepts, up
to a point, too. I, for one, am using Ruby more for enhancing my OOP
skills. I'll be using the other three languages I mentioned for my
further FP investigations, I'm sure. Of the two, I've already started
playing with OCaml and UCBLogo over the course of the last year, and
found a lot to like about both.
RSS Feed