MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Functional programming?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg92008] Re: Functional programming?
  • From: David Bailey <dave at Remove_Thisdbailey.co.uk>
  • Date: Tue, 16 Sep 2008 19:26:48 -0400 (EDT)
  • References: <200809130957.FAA03536@smc.vnet.net> <gal3dg$dql$1@smc.vnet.net>

peter lindsay wrote:
> as an old-timer myself - I'd be very interested in this too,
> particularly - as you say - with reference to engineering problems.
> I'm afraid my favorite construct was the REPEAT - UNTIL loop, which
> should finally ruin any shreds of credibility that I may once have
> had...

I think it is possible to frighten people off with functional 
programming. It is true that simple examples of FP can be much shorter 
than their procedural equivalent, and will almost certainly run much 
faster, but FP can become very messy for some real world problems, and 
procedural programming offers a way to 'hack' almost anything. I am 
tempted to give an example of something that is hard to do by FP, but 
someone will, of course, provide an answer - but that is not the point, 
the point is whether users with limited experience of Mathematica would 
be able to come up with such a solution.

There are quite a few While loops in my Super Widget Package!

I feel there is another thing to say regarding FP. The fact that FP 
performs so well in Mathematica is, in my opinion, something of a fluke. 
The real reason is that because Mathematica is such a high level 
language, absolutely every step incurs considerable overhead, that is 
not present in languages such as Fortran or Java. Because FP provides a 
way to do a lot in one step, it reduces this overhead.

Thus, for example, whole array operations (which are somewhat analogous 
to FP) in Fortran perform little if any better than explicit DO-loops, 
and re-coding a Fortran application to use whole array operations may 
reduce its performance because the cache utilisation can suffer.

David Bailey
http://www.dbaileyconsultancy.co.uk


  • Prev by Date: Re: Advanced plotting
  • Next by Date: Re: how to test where a list contains constant(s) or not
  • Previous by thread: Re: Functional programming?
  • Next by thread: Re: Re: Functional programming?