MathGroup Archive 2004

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

Search the Archive

Re: Programming style

  • To: mathgroup at
  • Subject: [mg47616] Re: Programming style
  • From: Bill Rowe <readnewsciv at>
  • Date: Sun, 18 Apr 2004 04:15:13 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

On 4/17/04 at 2:31 AM, lorenzo.keegan at wrote:

>Recently I bought the book "Mathematica - A Practical Approach",
>where different styles of programming are discussed, namely
>Functional programming versus Procedural programming.

>The book seems to suggest that most Scientist and "professional"
>Mathematica users prefer the Functional programming approach.

>What are your feelings ? Is it worth the effort to learn the
>Functional method ? Does it matter ?

If you will be using Mathematica extensively, then yes it does matter and is worthwhile to learn the functional paradigm. Mathematica seems to run much faster and more efficiently when functional programming is used instead of proceedural methods. For example, consider

Timing[For[sum = 0; n = 1,  n < 100001, n++, sum += n]]

{1.2999999999999998*Second,  Null}

Timing[Plus @@ Range[10000]]

{0.009999999999999787*Second, 50005000}

Additionally, to me the functional paradigm is easier to debug since I don't need to keep track of array lengths etc.
To reply via email subtract one hundred and four

  • Prev by Date: Re: Programming style
  • Next by Date: Re: Programming style
  • Previous by thread: Re: Programming style
  • Next by thread: RE: Programming style