MathGroup Archive 2004

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

Search the Archive

Re: Programming style

  • To: mathgroup at smc.vnet.net
  • Subject: [mg47608] Re: Programming style
  • From: "Mark Westwood [EPCC]" <markw at epcc.ed.ac.uk>
  • Date: Sun, 18 Apr 2004 04:15:04 -0400 (EDT)
  • Organization: Edinburgh University
  • References: <c5qj4q$fvh$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Lorenzo

Here's my five-pennyworth, I expect that many others in this newsgroup 
will chip in with their own strongly-held, entirely reasonable and 
mutually contradictory opinions:

Yes, it is worth the effort to learn the Mathematica way of doing 
things, the 'functional' method as you put it, just as it is worth the 
effort to learn the object-oriented way when learning Java or Smalltalk 
etc.  Their are two reasons for making the effort:

1) equivalent programs written in the functional style and the 
procedural style usually execute faster, in Mathematica, in the 
functional style;

2) functional programs are often shorter, easier to write and easier to 
understand than procedural programs - once you have enough experience of 
Mathematica that is;

3) writing functional-style programs is much more natural in Mathematica 
than writing procedural programs; when I try to write procedural 
programs in Mathematica I always feel that I am fighting against the 
system rather than with it.

(OK, so that make's three reasons ...)

In my second paragraph I place the word functional in quotation marks, I 
  won't be surprised to read other answers to your enquiry which deny 
that Mathematica is a functional language - pure functional languages 
don't do assignment for instance.  I think it's functional enough to be 
considered a functional language.  But you should also make some effort 
to get your head around the concept of Mathematica as a term rewriting 
system, transforming expressions in one form into an equivalent (usually 
simpler) form.

If the book you have is the one by Nancy Blachman then stick with it.  I 
think it is the best introductory text for general purpose Mathematica. 
  Once you've finished with it you will be ready to digest The 
Mathematica Book itself.

good luck

Mark


lorenzo.keegan at handbag.com wrote:
> Hello,
> 
> I am an experienced computer programmer having used ADA, C, Visual Basic
> etc. for years.
> 
> 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.
> 
> For years I have been working with the "Procedural" method.
> 
> What are your feelings ? Is it worth the effort to learn the Functional
> method ? Does it matter ?
> 
> Thanks for your time
> 
> Best Wishes
> Laurence Keegan  
> 


  • Prev by Date: Re: DSOLVE in 5.01 ??
  • Next by Date: Re: Incidence/frequency of numbers in lists
  • Previous by thread: Re: Programming style
  • Next by thread: Re: Re: Programming style