开发者

What do I learn to "enlighten myself with the ways" of functional programming?

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 l开发者_Go百科earn to "enlighten myself with the ways" of functional programming? Haskell, Scheme or CLisp?


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.


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.


All three are good, depends on each person.

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


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.


'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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜