Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2004
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: Programming style

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

On 4/17/04 at 2:31 AM, lorenzo.keegan at handbag.com 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

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

Out[1]=
{1.2999999999999998*Second,  Null}

In[2]:=
Timing[Plus @@ Range[10000]]

Out[2]=
{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