MathGroup Archive 2008

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

Search the Archive

Re: Functional programming?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg92046] Re: Functional programming?
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Thu, 18 Sep 2008 06:14:53 -0400 (EDT)

On 9/16/08 at 7:26 PM, dave at Remove_Thisdbailey.co.uk (David Bailey)
wrote:

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

I think it is also true procedural programing can become messy
for some real world problems. Consider something that requires
deeply nested For loops. Keeping track of loop indices for such
a problem certainly seems messy to me.

>and procedural programming offers a way to 'hack' almost anything.

and I believe the same can be said of functional programing

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

Why is this the point? For any capable system similar to
Mathematica, whether functional based or procedural based, it
should always be possible to find examples of problems that
users with limited experience with that system will not be able
to come up with a simple solution much less an optimal solution.
This follows essentially by definition. Systems where it would
not be possible to find such problems surely lack rich toolset
offered by Mathematica.

Debating which is better (functional programing or procedural
programing) is analogous to debates of early calculators
comparing HP's RPN style to TI's algebraic style. Either could
get the task done. And it was possible to find example problems
that were more efficiently done by one than by the other.

I don't think the point should be finding example problems or
whether users with limited experience can solve a particular
problem with functional programing. The bottom line is,
Mathematica performs better with functional programing than
procedural programing. And I believe once a user becomes
familiar with Mathematica's functional programing, he/she will
find the functional approach more efficient and easier to debug/maintain.

To me, using Mathematica without learning functional programing
is somewhat analogous to driving a sports car without learning
to use the higher gears. You can get from point A to point B in
a sports car using only first gear but clearly that isn't
efficient use of the sports car. Similarly, you can solve
problems with Mathematica using procedural programing but that
isn't efficient use of Mathematica.


  • Prev by Date: Re: How to separate a sum into terms
  • Next by Date: blurry ellipse
  • Previous by thread: Re: Functional programming?
  • Next by thread: Re: Functional programming?