in reply to programming languages and immutable data types
The problem with mandating that strings be immutable, is that whilst it works okay for occasional modifications to run-of-the-mill short strings, it imposes a high cost on frequent changes to large ones.
And as "strings" are frequently the only mechanism for allocating (often) large chunks of memory for use (for example) as buffers, it can extract a high cost. Effectively discarding one of the primary benefits of threads over separate processes.
Imagine the cost of the use of ramfiles if every write had to duplicate the buffer.
Allowing, and even defaulting strings to immutable makes some sense, provided that you retain the ability to also allocate mutable chunks of ram. Immutability is an artificial constraint born out of a particular viewpoint of programming. Imposing it upon programmers is like imposing vegetarianism upon the world.
|
|---|