Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Speeding up code

  • To: mathgroup at smc.vnet.net
  • Subject: [mg100470] Re: Speeding up code
  • From: Andreas <aagas at ix.netcom.com>
  • Date: Fri, 5 Jun 2009 03:00:58 -0400 (EDT)

DH always has great ideas into how to speed up and optimize code.  I thought of him and this question when I came across this insight into the general question:

Kas Thomas recounts the following advice he got early in his career on how to write fast code at his blog:
 http://asserttrue.blogspot.com/2009/03/how-to-write-fast-code.html

A short snippet of a conversation between Kas and his mentor follows:

"'The CPU,' he said, 'runs at a certain speed. It can execute a fixed number of instructions per second, and no more. There is a finite limit to how many instructions per second it can execute. Right?'

'Right,' I said.

'So there is no way, really, to make code go faster, because there is no way to make instructions execute faster. There is only such a thing as making the machine do less.'

He paused for emphasis.

'To go fast,' he said slowly, 'do less.'

To go fast, do less. Do less; go fast. Yes, of course. It makes perfect sense. There's no other way to make a program run faster except to make it do less."

Me again -- All of these almost magical things Mathematica does with optimizing list operations and functional programming constructs, all of them, let run code faster because it  lets it do less.  Simple and elegant, the haiku form of programming languages.  

Best,
A


  • Prev by Date: Repositioning AxesLabel position
  • Next by Date: Re: Problem with a plot in Mathematica
  • Previous by thread: Re: Speeding up code
  • Next by thread: Reverse Geocoding code