marcinmoskala
06/03/2024, 2:36 AMMarco Pennekamp [JetBrains]
06/04/2024, 4:58 PMModifications to var with read-only collection require making a copy of the entire collection. For large collections, that is a heavy and memory-consuming operation.Persistent data structures alleviate this issue by sharing parts of the data with the previous collection before the operation. I think they aren’t as popular in Kotlin as in languages like Scala or Clojure, where more emphasis is placed on immutability. But for most use cases, persistent data structures offer a great balance between performance and correctness/maintainability. So much that, in my opinion, they should be considered as the default option in most projects.