3 ms·
>Erlang does not use a contiguous chunk of memory to represent a sequence of bytes. Instead, it represents a sequence of bytes as nested lists of non-contiguous
by jere 14y ago
>Erlang does not use a contiguous chunk of memory to represent a sequence of bytes. Instead, it represents a sequence of bytes as nested lists of non-contiguous chunks of memory. The result is that concatenating two strings takes O(1) time in Erlang, compared O(N) time in other languages.
I've often wondered if this was being used anywhere. It seems like such an easy win, but now I'm curious if it would causes problems with cache misses or something.
- masklinn 14y agoOther commenters have noted that writev(2) is quite similar (although from reading the man page, it does not seem you can put iovecs inside an iovec, so there's only one level of nesting)
- noselasd 14y agoThis approach is used by Scala with its immutable vector, and many other functional languages have a similar thing.