
And that would be true if everything were strict and not partially evaluated
sometimes :-)
My understanding is the following... (and I could be way off)
Remember that a function of arity N is really N functions of arity 1 with
their arguments bound one at a time to create a new function along the way.
At least you *can* write your code that way if you really want to, but the
laziness might make it such that all the parameters are not bound, due to
not being "needed" at that moment. Instead a thunk or what some other
languages might call a "Future" is put in the argument's place, to be
evaluated when needed.
If Haskell were strict by default, I think your claim of passing references
around could be true, but my experience with Haskell has been that sometimes
it's too lazy for me to write the code that I first thought would be
efficient without a lot f study and refactoring of that code.
I'm sure this gets easier with practice, but it's not something I was
expecting to be as difficult as it all was.
Dave
On Thu, Dec 10, 2009 at 5:57 AM, Alberto G. Corona
One more advantage that is not frequently cited
Purity permits to pass every parameter of a procedure by reference (giving the pointer) rather that by value giving a copy, and still be sure that the data has not been modified. Besides the safety. this is great language optimization itself.
2009/12/10 Alberto G. Corona
What material benefit does Haskell derive from being a "pure" functional language as opposed to an impure one?
Here is my list of benefits of purity (some of them are enhanced by other features like the type system).
Purity means referential transparency. that means that the programmer has no way to modify pure data. That cut the tree of possible programmer errors.In particular, since there are no variables, every state change must be in the form o a call to a function with new parameters. each function has no state change (except when needed and then the type system labels the stateful code as such)( This enforcement goes in the righ direction for clarity and readability, maintainability, modularity xxxxxbility.
Purity also eases paralel processing, since no data is modified, each process is isolated better. Less opportunities for errors.
Purity permits lazines because since the execution tree of an expression has pure, data, can be evaluated later, since it will not be changed.
Lazy evaluation eases mathematical reasoning,because mathematics has no notion of eager evaluation, but to make use of mathematical equations when the calculation is needed. .
Mathematical reasoning permits the full use of a long tradition of mathematical knowledge. This makes code more simple, understandable, general, proof guarantted and elegant (for those that know the mathematical domain). This also permits high level optimization of code, both by the programmer and the compiler.
for sure there are a few more
We are superstitious and guided by "nonrational" ideas such is beauty. but:
bauauty -> (simplicity -> (less effort to master, less errors) , utility ->, solve more problems, solve greater problems )
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe