On 21 June 2011 03:40, Steve Lindsay <[email protected]> wrote:
> On Jun 21, 3:01 am, Kirk <[email protected]> wrote: > > > > Again, I'm not against immutability, it just seems that we've all picked > up on that sound bite and have forgotten all of the other colors that make > the world interesting. > > > > Hasn't most of the immutability push (outside of this thread at least) > been about safety, maintainability, ability to reason about complexity > etc., rather than performance? > > Oh absolutely. It's very refreshing being able to see some value declared at the top of a class and being certain that it's exactly the same thing further down the file. This becomes even more useful if you want to be certain that some other thread also hasn't fiddled with it. It's also much easier dealing with pure functions, guaranteed to always do the same thing for the same input and not have side effects. Referential integrity means that you can substitute a function call with its precalculated result; this particular optimisation is almost as old as programming itself, with one classic example being a lookup table of trigometric functions. So dropping immutability is a very useful optimisation, but it certainly isn't the only one in our toolbox, and there are other optimisations that immutability makes possible. As always, we're better off starting with clean and provably correct code, then letting a profiler be our guide as to where speedups can be found. -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
