views:

126

answers:

6

I've been coding for a few years now, nothing too complicated. C++ is what i know best. I recently stumbled into Paul Graham's site, coding horror and now here. What do i learn to 'enlighten myself with the ways' of functional programming?

+3  A: 

Of the three, I'd say Scheme is the simplest overall, if that's your main concern. SICP uses Scheme, and is itself a great resource for learning to program the functional way.

However, Common Lisp has many advanced features that make it quite expressive, such as powerful error handling (more powerful than exceptions), multimethods and support for aspect oriented programming.

You might start with one but, in the end, you should study many languages.

outis
+1 for SICP, it's a great way to learn
Isaac Cambron
Common Lisp really does have a lot of cool features, but most of them are unrelated to functional programming.
Chuck
@Chuck: very true. That's one reason I recommend Scheme over Common Lisp to start. I'm just such a fan I can't help but mention some. Vivant NCITS/J13.
outis
+4  A: 

All three are good, depends on each person.

If you decide on haskell, this is a great ressource : learnyouahaskell and also real world haskell

David V.
+1  A: 

As other answers say, all three are good.

But if you decide on Lisp, then I'd suggest you go for Clojure which is perhaps its most recent reincarnation.

missingfaktor
Clojure is pretty nice if you want OO Lisp, but it's a poor choice if you want to learn functional programming. It doesn't even do tail-call elimination!
Porculus
@Porculus: Clojure doesn't do tail-call elimination thanks to trouble integrating that with Java, but it does allow recursive solutions with the `recur` operator. From what I know about it, it still seems more strongly functional than Common Lisp.
Chuck
+7  A: 

If you're interested in functional programming, Haskell is the only purely functional language on that list. Common Lisp is a weakly functional mixed-paradigm language, and Scheme is more strongly functional but still not pure. Lisps are interesting for other reasons, but Haskell is pretty much the state of the art for functional programming.

Incidentally, the reason I encourage more strongly functional languages like Haskell is because a large part of "learning functional programming" is learning how to think of your program in a different way. If your language makes it feel natural to write imperatively, it's too easy to fall into that way of thinking and never realize there's a different way to do it.

Chuck
I like your reasoning
NomeN
+2  A: 

'enlighten myself with the ways' of functional programming?

Haskell's the strongest exemplar of the functional style, emphasizing purely functional programming (no side effects), strong static typing, and with a pragmatic implementation with an emphasis on multicore parallelism, while also having a huge community (around 2000 libraries available on http://hackage.haskell.org , and many online resources).

It's somewhat famous for retraining how people think about programming.

But this is advocacy, and not a useful stackoverflow question and answer session. You'll have to decide for yourself what you're looking to learn.

Don Stewart
+3  A: 

Have you heard of F#, ML or OCaml? These three languages belong to the ML family.

F# is a new ML dialect supported by Microsoft and will be shipped with Visual Studio 2010. The good thing about F# (or other ML languages) is that when you first start you could write imperative code and learn good functional style gradually.

Here's an example I wrote for Project Euler #2. When I first did it, I used imperative style. Later on, I know how to use lazy sequence, which is a powerful functional programming concept.

Yin Zhu