Question

I am looking to learn functional programming with an am to integrate Boost.phoenix into my project.

What language is most similar so that I can find books that will illustrate functional programming concepts in a way that can be readily applies in that context... Are haskell and ocaml similar?

ALternately are there any good functional programming books written in general terms that can be applied to Boost.phoenix?

Was it helpful?

Solution

I don't have any experience with Phoenix (I've skimmed the docs), but I do have some with C++, OCaml, and Haskell so I may be able to help there.

First off, if you learn functional programming you'll find it doesn't translate prettily to C++ - it ends up messier and more verbose than if done in an actual functional language. Nevertheless, it is still worth learning the techniques as they will give you more tools and a different mindset.

Are haskell and ocaml similar?

They are both influenced by ML so they are quite similiar (well, sorta, see the comments). OCaml is closer to C++ because of it's imperative and OO features, but I recommend you learn Haskell as it is more functional, more mindbending, and has more resources. An interesting thing about ML-like languages that they translate quite nicely to template metaprogramming.

ALternately are there any good functional programming books written in general terms that can be applied to Boost.phoenix?

The docs of Phoenix seem to use fairly standard terms. The one thing which could be confusing is their use of the word 'functor' - in C++ it means function object but in languages like Haskell it is something else.

Here are a few terms that you should look for:

  • lambda / anonymous function
  • first class function
  • function application
  • partial application and currying
  • composition
  • strict/non-strict/lazy evaluation
  • recursion
  • closures

Here are two free books which I recommend reading as they are a great introduction to functional programming:

http://learnyouahaskell.com/chapters (Haskell)

http://mitpress.mit.edu/sicp/full-text/book/book.html (Scheme)

OTHER TIPS

Phoenix enables functional programming (FP) in C++. Consequently, the language that will be most synergistic is going to be C++.

If you want to learn functional programming on its own terms, languages like Haskell and Scheme may be better choices.

http://www.boost.org/doc/libs/1_51_0/libs/phoenix/doc/html/index.html

I don't know much about Phoenix but I think that Okasaki's Purely Functional Data Structures can give you more or less general look how to write programs in functional style.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top