Rich Hickey's slides from jvm lang summit - worth a read?

Walter Bright newshound1 at digitalmars.com
Fri Sep 25 17:08:17 PDT 2009


Jason House wrote:
> Walter Bright Wrote:
> 
>> bearophile wrote:
>>> Walter Bright:
>>> 
>>>> Executive summary: pure functions and immutable data structures
>>>> help manage program complexity.
>>> At the moment in D there aren't many immutable data structures
>>> available, but of course they can be written. Such data
>>> structures often put the GC under some/high pressure. I don't
>>> know if the current D GC is able to cope.
>> I don't understand your comment. With immutable being transitive,
>> any data structure can be made immutable. The GC doesn't care if a
>> data structure is immutable or not, I don't see how that affects
>> its operation.
> 
> Think about what happens when you want to mutate an immutable data
> structure. You must create one or more new objects. That increases
> the number of objects for the GC to handle

On the other hand, immutability means that diverse data structures can 
share parts of them, reducing the number of objects. I find that 
immutable strings means my programs allocate far fewer strings, as it is 
no longer necessary to defensively make copies "just in case" something 
else changes them.

I've been thinking of transitioning dmd's semantic analysis to using 
immutable data structures because it will reduce allocations, not 
increase them.



More information about the Digitalmars-d mailing list