Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*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 2006

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

Search the Archive

Re: General--Difficulties in Understanding Mathematica Syntax

  • To: mathgroup at smc.vnet.net
  • Subject: [mg69041] Re: General--Difficulties in Understanding Mathematica Syntax
  • From: Bill Rowe <readnewsciv at earthlink.net>
  • Date: Sun, 27 Aug 2006 01:24:24 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

On 8/26/06 at 2:04 AM, siegman at stanford.edu (AES) wrote:

>Concepts like Map[ ], Thread[ ], Apply[ ] are thoroughly understood
>by adepts, and marginally understood by some of the rest of us. 
>They're not concepts, or terms, commonly used in everyday speech. 
>And they may have some hidden subtleties in their operation, even
>some "gotchas", in how they apply to what's inside the [ ]s.

>Constructs like Do[] , If[ ], While[ ] are fairly likely to be
>understood not just by adepts, but by anyone who's ever done even
>very elementary programming in (horrors!) BASIC.  Their programming
>use matches up pretty well with the same terms in everyday speech. 
>They make the flow of the program logic more obviously visible (at
>least to us non-adepts).  And I suspect they have fewer hidden
>gotchas.

<snip>

>What is it that's actually **better** (for the "ordinaryt user")
>about these more sophisticated constructs?

>*  Faster, more efficient execution? -- perhaps so, but in the vast
>majority of cases, who cares?!?

The difference in execution speed can easily be 2 orders of magnitude or more. This is enough performance difference to be the difference between a problem that can be done and one that cannot be done.

>*  More accurate execution?  -- I sure hope not.

Yes and no. No, in the sense that correct code written with procedural programming will produce the same results as those obtained with Map and the like. But the code with Map is simpler since I do not need to worry about indexing. For example, a typical error when coding with For loops to index an array is to be one off, i.e., using say greater as the stopping criteria when it should have been greater than or equal. Since indexing is never explicitly coded with Map, this error cannot happen.

Once you become accustom to using Map, Apply etc. you will find additional benefits besides improved execution speed. Your overall productivity will improve since you will no longer need to worry about indexing of arrays, how long an array is etc. This allow you to focus more on the problem being solve rather than worrying about low level implementation details. And this in turn, will give you greater confidence in the completed code.

Yes, it requires a bit of effort and time to become proficient in using Map etc since they are quite different than procedural programming constructs. But I believe it is time and effort well spent, particularly if you use Mathematica as frequently as I do.
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: General--Exponential simplifications by default
  • Next by Date: Re: Re: General--Difficulties in Understanding Mathematica Syntax
  • Previous by thread: Re: Re: General--Difficulties in Understanding Mathematica Syntax
  • Next by thread: Re: General--Difficulties in Understanding Mathematica Syntax