On 10/8/06, ihope <[EMAIL PROTECTED]> wrote:
On 10/8/06, Yang <[EMAIL PROTECTED]> wrote:
> And do most (experienced) Haskell
> users sacrifice cleanliness for speed, or speed for cleanliness?

Keep the internals of your code--that which will be looked at a
lot--fast and ugly, while the rest can be clean. If you have a
function that does something very simple, but the "pretty" way to do
it takes a second to run while the ugly way is much, much faster, use
the pretty one if it's only going to be needed once or twice. It's
certainly not the kind of thing you want to fold your lists with: use
the ugly version for that.

Also, if you want, you can write both a pretty version and an ugly
version, and put the pretty version in comments while the ugly version
does all the real work.

Another good idea when you have a pretty version which is easy to
verify for correctness and an ugly version that is harder to verify is
to use QuickCheck or SmallCheck and define a property that says both
versions are equal for all inputs.  Ugly code is notorious for holding
bugs, but doing this would help test the ugly code.

Jason
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to