[Haskell-cafe] Using Product Algebraic types
Crypt Master
cryptmaster at hotmail.com
Mon Jul 5 13:53:34 EDT 2004
-------------
<sigh>
I always get a bad feeling when people start to think about efficiency
right
from the beginning: First get your program correct and readable, then
measure,
and only then optimize (if at all). Programmers are notoriously bad when
guessing about efficiency, which even more true for lazy functional
programs.
</sigh>
------------
Sorry to have produced the *sigh* factor. I asked the question only to start
learning, which your answer has certainly helped me with.
Maybe I can present a differnt persepctive on performance though. I have to
say up front though that if I was interested in squeezing the last drop of
performance out of everything I wouldnt be learning haskell as all the web
sites warn you about this :-) I do beleive in clarity, readbaility,
correctness, time to develop etc.., it just that performance is one of those
factors.
My day job is all mostly about performance (from iterative programming
perspective), I make complex business applications useable from a
perfromance perspective. While most people say "just buy more hardware" or
make it "correct or readable" first, my experince shows this leads to a lot
of wasted effort which could have been avoided with a few seconds thought.
Have you ever tried telling an IT Director that his 500 000 - 1 000 000
pound equipment purchase isnt cutting it for a "simple" business application
:-) Let me tell you, they can have really selective hearing when it suits
them :-)
In my world, getting a program "correct" includes effieincy within reason.
For exmaple, a 5 minute response time for interactive process can be pushed
on employees with a relativilty minial cost of a small loss in productivity.
However 5 minutes as a response for customer sitting on your web site is
going to cost you millions and probably put you out of business. There are
dozens of senarios like this where a "correct" program is as good as no
program if it doesnt perform fast enough.
What you say about guessing at performance is correct. I have given lectures
on performance which start off with slides which say the trick to
performance tuning is:
"Measure, Measure, Measure"
But I have found through experience (in the iterative world) that certian
patterns of bad performance are easily avoided at development time because
we know from experince they are bad at runtime.
Performance has 3 flavours in my mind:
1) Hard Core
2) Design (Algortihms and data representation)
3) Common sense coding
The fiirst, Hard code, invovles assemlber optimizations, branch reductions
using boolean algebra etc.. No one argues these are mostly not worth the
effort and so these are mostly ingnored expect for very special
cercumstances. The phrase "buy more hardware" applies in this case 99% of
the time.
At the other end of the spectrum you have design. Few people will argue that
getting your design right up front is very important. Changing Algorithms or
Data Representation usually invovles changes of a significance that you have
wasted your time on the "incorrect" version as you are starting mostly from
scratch. Admitatly this looks a lot easier in haskell than in other
impertive lanaguages.
The 3rd area is where I differ from most people. Common sense coding is
simply not calculating or looking something up over and over in an inner
loop etc... While the programs can be changed afterwards to incorporate
these, a few seconds thought by the developer avoids the bottle neck in the
first place. An Example of the impact of such ineffiencies is this:
Recenetly I "optimized" an interactive job which was taking over 10 minutes
to run. Without understanding much about it (its highly complex) I was able
to bring it down to < 1 minute applying simple common sense things. I never
changed or looked at the "logic" behind it. Happy user base = productive
company :-)
That said haskell compiler seem pretty smart from what you have shown me so
far ... which is a welcome change :-)
Thanks for your reponse. This is the most helpfull community I have
encountered so far .. :-)
_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail
More information about the Haskell-Cafe
mailing list