Boost logo

Boost :

From: Brian McNamara (lorgon_at_[hidden])
Date: 2004-02-23 17:37:25


On Sat, Feb 21, 2004 at 10:19:02AM -0000, Andy Little wrote:
> Functional programming' basically separates 'Joe User' from 'Johnny Guru'.
...
> I am being too dismissive about 'Functional programming' . Basically it is
...
   [ much more of the "cynic's view of FP" elided ]
...
> Execution order not guaranteed... :-)
> No assignment ...No variables... (hmm.. because Execution order not
> guaranteed)
>
> IOW its an entirely Different Programming Paradigm . FP doesnt have any OOP
> concept, its not 'close to the machine'
> I'm not against it outright(Some of the above ideas are very useful in
> certain areas...e.g parallel processing) but it seems daft to mix it with
> C++.

I agree with some of your comments here about FP in the C++ setting.
Specifically, absolute purity (side-effect freedom) trades away
assignment and mutable variables in order to buy freedom of evaluation
order, which can be useful for compiler optimizations, especially in
parallel settings. Since C++ clearly has effects and assignment (and
the C++ compiler is not going to employ the same kinds of optimizing
transforms common in pure languages), purity is not going to be a big
win here.

But there's more to FP than just purity. Higher-order functions,
lambda, and closures let you write code in a more applicative style,
which can raise the overall level of abstraction. Features like these
do "mix well" with C++ or other OOP languages. Indeed, recent OOPLs
have been including various functional features: for example, Python
has lambda and list comprehensions, and Scala has lambda as well as
generalized monadic comprehensions in its "for" statement. Functional
programming is a wide umbrella, and though not all of it mixes well
with OOP, a number of features do work synergistically between the two
paradigms.

As an aside, it occurs to me that I've been remiss in failing to mention
"algebraic datatypes" and "pattern matching". These are other features
commonly associated with FP, and these features also mix well with OOP
(see e.g. Scala and Nemerle). FC++ doesn't include any support for
these features, but I should have at least mentioned them in my other
messages about FP.

Thanks to everyone for your comments so far! Remember that the review
for FC++ has been extended (until March 1); comments along the lines of
   http://www.boost.org/more/formal_review_process.htm#Comments
are very much appreciated.

-- 
-Brian McNamara (lorgon_at_[hidden])

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk