3 ms·
How do you mitigate overhead from making copies all the time with immutability? By using moves and changing ownership a lot?
by CardenB 8y ago
How do you mitigate overhead from making copies all the time with immutability? By using moves and changing ownership a lot?
- campezzi 8y agoSome languages deal with this better than others through structural sharing, which reduces overhead significantly. The performance hit is usually unnoticeable in those languages and only becomes a problem in very specific cases ie. processing large strings, appending items to long lists, etc... some of those will cause you to rethink the way you do certain things (that is part of the FP journey). In languages like JS or Ruby though, you might need to compromise. Generally I start with the immutable approach and refactor if performance becomes an issue.