:mega: :mega: We'd like to announce the second rel...
# announcements
i
📣 📣 We'd like to announce the second released version of
kotlinx.collections.immutable
library — 0.2 Thanks to the great effort of @Abduqodiri Qurbonzoda [JB] we now have modern and efficient implementations of persistent collections rewritten from scratch. That allowed us to improve performance characteristics of many collection operations. See more details in the changelog: https://github.com/Kotlin/kotlinx.collections.immutable/releases/tag/v0.2 Another notable change is that we have split each collection interface there into two parts: an
ImmutableCollection
that merely extends a read-only
Collection
and adds a contract of immutability on top of it, and a
PersistentCollection
that additionally provides modification operations and builders. We encourage you to try it and share your feedback, but note that the library is still pre-release, so the API and implementations can change in future. Currently this library is provided only for JVM, but our next short term plan is turning it into a multiplatform one.
K 7
👍 5
🎉 24
🍾 3
r
Is there any plan to have
listOf
etc. return these instead of using mutable collections under the covers? Or will these stay in
kotlinx
?
e
They will stay in a separate library.
👍 1
t
@ilya.gorbunov This is so cool! I wrote a blog recently about a quick intro to persistent lists in Kotlin and was talking about how I liked persistent data structures in other languages like Scala and F#. So, this is a really exciting announcement! Thanks so much 🙂
t
noob question, why this is a good thing?
k
For the immutable collections, you can require that parameters to your functions are really immutable, and you can freely store them for later use without any defensive copies. If you would just take a
List
you promise that you won't modify it, but the caller doesn't promise anything. For the persistent collections, it's nice to be able to do do things like
list1 + list2
and
for (x in list1 + extra)
without having terrible performance because of all of the copying.