3 ms·
It makes no sense to choose immutable values for the multithreading performance benefit. You can usually get a much larger benefit from using a single threaded
by millstone 9y ago
It makes no sense to choose immutable values for the multithreading performance benefit. You can usually get a much larger benefit from using a single threaded mutable implementation. For example, a mutable hash table will outperform a persistent hash-tries for updates.
(Of course there are good reasons for using immutable values; performance is just not one of them.)
Swift collections are logically immutable but may mutate under the hood if there is a unique owner. This conceptually provides a best-of-both-worlds, but a downside is that the language does not provide much help to enforce single-owner (yet).