Hacker News new | ask | show | jobs
by eru 5546 days ago
If your compiler is smart enough (i.e. you are programming in clean, or use Haskell's GHC) the `copy penalty' can be zero for objects that only have "one future", i.e. you only ever keep one copy of your structure. (And that's still cleaner and safer than mutable structures.)

The `copy penalty' for multiple uses of your objects, say a = update1 (x), b = update2 (x), does not depend so much on the size of your object as one the amount of sharing you can do. Immutable objects allow sharing. For mutable ones you have to work much harder.