I've been looking at the new features in c++0x and it really looks like it will be possible to program in a very functional programming style using it. I've gotten use to using the types List, Seq, Array in f# and I see no reason why their members couldn't be ported into some sort of c++0x template. It looks like microsoft is trying to do that with their STL Algorithm class. What problems of advantages do you see in using c++0x vs something like f# for a mixed functional programming style? Maybe the Boost guys will make a new functional
once c++0x comes out.
views:
523answers:
3
A:
I imagine that it would be… interesting… to implement certain optimizations common to functional languages in C++0x (like common subexpression elimination).
John Calsbeek
2009-07-06 21:08:08
Most C and C++ compilers do CSE and GCSE. This is not the problem. The problem involves partial function application and tail recursion.
Christopher
2010-07-29 20:57:23
+10
A:
The biggest problem with trying to program in a functional style in C++ is that it does not support tail recursion. In a functional language you don't have to worry about stack explosion when you tail recurse correctly, but in C++ you always have to worry about that. Therefore, many "functional" type algorithms will be clumsy or heavy.
Christopher
2009-07-06 21:16:53
Thanks! A starting point for a full implementation would be boost's range and iterator libraries, some combination of the two.
Daniel Earwicker
2009-07-24 21:05:10