Re: Functional Programming in the Larger or Functional Oriented Software Engineering
"Joe Marshall" <[email protected]> Mon, 2 Apr 2007 09:38:57 -0700
| Newsgroups | gmane.comp.lang.lightweight |
|---|---|
| Message-ID | <[email protected]> |
On 3/31/07, Robbert Haarman <[email protected]> wrote: > > Err, did you just illustrate how not using mutation can be beneficial in > resource-constrained environments by introducing memoization and hash > tables, both of which involve mutation?!?! Yes I did. HOWEVER, unless you have a computer to which you continually add hardware, you will have mutation. Mutation can exist at several levels of abstraction, and you can hide mutation behind an abstraction barrier so that the upper levels cannot observe it. (For example, garbage collectors do this all the time.) Memoization and hash-consing are both below the level of abstraction of the memoized code. If the code in the upper layer is purely functional, you can gain substantial speed and space savings in the lower layer through the use of carefully controlled resource management (which may involve mutation). On the other hand, if the code in the upper layer uses mutation in an unconstrained way, the lower layer cannot optimize resource management. In fact, the lower layers may have to use even more resources for copying of potentially mutable structure. -- ~jrm