MathGroup Archive 2008

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

Search the Archive

Re: Functional programming?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg92124] Re: Functional programming?
  • From: Szabolcs Horvát <szhorvat at gmail.com>
  • Date: Sat, 20 Sep 2008 05:02:12 -0400 (EDT)
  • Organization: University of Bergen
  • References: <200809130957.FAA03536@smc.vnet.net> <gal3dg$dql$1@smc.vnet.net> <gapfbe$o63$1@smc.vnet.net>

David Bailey wrote:
> 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. 

I think that the problem is that many people assume that once they have 
learned one computer language, they know all of them.  E.g. once one has 
learned Pascal, one can just learn the "translation" of all the 
words/constructs to C, but there are almost no new concepts.

This does not work with Mathematica.  Just learning the translation of 
common C words/constructs will not get one very far with Mathematica 
(but it can get one very frustrated with it ...).  Mathematica has many 
concepts that simply do not exist in any procedural language, and 
learning these concepts is more comparable to learning one's first 
programming language (and thus requires a much larger effort) than 
translating between similar procedural languages like e.g. Fortran and C.

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

This is a very good point.  An effective use of Mathematica is not at 
all the same as using pure FP.  In fact some practices that are very 
common to FP languages are not advantageous at all in Mathematica---just 
think about replacing loops with recursion, in particular looping 
through lists with recursion.  Since Mathematica lists are arrays (and not 
linked lists) this is a bad thing to do in Mathematica (unless one builds a 
linked list like this: {{{},a},b},c}).


  • Prev by Date: Re: Debracketing array symbols
  • Next by Date: Re: Re: Apparent error integrating product of DiracDelta's
  • Previous by thread: Re: Functional programming?
  • Next by thread: Re: Functional programming?