Kinds of containers
Timon Gehr via Digitalmars-d
digitalmars-d at puremagic.com
Wed Oct 21 10:23:34 PDT 2015
On 10/21/2015 06:25 PM, Jonathan M Davis wrote:
>
> My experience with immutable containers is that their performance is
> trash precisely because you can't mutate them. They end up being copied
> just to add elements or to change elements.
I don't think this is what's being proposed here. Updates are fast.
> And even if their internals
> are smart and share data as much as possible (though that starts moving
> into COW pretty quickly),
COW copies the entire container.
> the efficiency is still worse than having a
> properly mutable container would be.
Not if you need access to older versions. If this is the case, then the
"properly" mutable container carries a lot of runtime and memory
overhead due to copying. Also, the difference is not very large for good
implementations.
> I'm sure that there are use cases
> where they would be useful, but I've sure never had one. I've found that
> functional languages can be great from an algorithmic perspective, but
> for data structures? Not so much.
It's not tied to the language.
More information about the Digitalmars-d
mailing list