Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

production-ready? or, roadmap? #120

Open
cprice404 opened this issue Nov 1, 2021 · 7 comments
Open

production-ready? or, roadmap? #120

cprice404 opened this issue Nov 1, 2021 · 7 comments

Comments

@cprice404
Copy link

Hello! Just checking in to see if there is any new info on whether or not this library is considered production-ready, or if there is a roadmap for how/when it may get there?

I reviewed these issues:

#26
#6

And it sounds like the current collection implementations are probably considered reasonably state-of-the-art, and thus I would assume that the path to production-readiness would just be some combination of testing / benchmarking / bug-fixing.
However the README still uses the word "prototype".

We need some persistent collections in our production Kotlin app and this library would be our first choice if it is on a path to 1.0, but we're currently comparing/contrasting to other libs such as vavr since it is not entirely clear. Thanks in advance for any more up-to-date info you are able to provide!

@qurbonzoda
Copy link
Contributor

Hi @cprice404 !
Although the implementations are based on the best data structures we could find, this library is not declared stable yet. Thus we can't recommend it for production use.
Currently, the project is in maintenance/bugfix mode, and 1.0 is not scheduled for the near future.
If you decide to use the library in any of your projects, we would be happy to hear your feedback.

@cprice404
Copy link
Author

We are trying it out and it seems to be going well so far, but would really love to see it have a path towards GA.

Does the kotlin team have a different JVM persistent collections library that you would recommend in the absence of this one being production-ready? This seems like a pretty big language gap for developers coming from functional languages like Scala and Clojure.

@mcpiroman
Copy link
Contributor

FWIW Compose, which is considered production ready, does use (a copy of) this library internally - https://github.com/androidx/androidx/tree/androidx-main/compose/runtime/runtime/src/commonMain/kotlin/androidx/compose/runtime/external/kotlinx/collections/immutable

@qurbonzoda
Copy link
Contributor

qurbonzoda commented Nov 21, 2021

Unfortunately, we don't have any endorsed persistent collections library for now. In a JVM-only project, any of the available libraries (e.g. vavr, PCollections, Javaslang, ...) could be used. However, the Kotlin team does not vouch for their quality.

@qurbonzoda
Copy link
Contributor

Just to make clear, an unstable (or not production-ready) library in Kotlin is not necessarily of bad quality. It just indicates that the library API is not stable, i.e. in future releases existing functions or interfaces could be renamed or removed, or their behavior could be changed with shorter deprecation and migration cycles.

Before promoting this library to 1.0 we would like to add more tests, discuss the library public API, and address feedback we have already received(e.g. #66, #106). However, there is no timeline currently to share.

@qurbonzoda
Copy link
Contributor

Hi everyone,

We now have a roadmap that will lead the library to Beta and eventually to a stable release. I have outlined it here: #185

@Sporking
Copy link

I really hope that this library eventually comes up with some fully supported, first-class, truly immutable data types that I can use. I have no use for the "Persistent" data types that this project has mostly focused on so far. I don't need to construct immutable instances incrementally, Lisp-style. I just need to be able to create frozen copies of data structures so that I can be assured they won't change anymore, under any circumstances. (Basically what Google Guava allows.)

I had high hopes when I first heard about this project. However, most of the focus on this project has been on persistent data types so far, and it seems that data types that are immutable, but not persistent, have been given little attention. It has been most of a decade that I've been asking for progress on this, and unfortunately I haven't really seen much progress, so I have been using Google Guava instead, with the following set of extension functions to make it appear more Kotlin-like.

These extension functions for Guava are a bit hackish, but they actually meet all of my current needs (but maybe not my future needs). Hopefully this will be useful to someone else as well.

import com.google.common.collect.ImmutableList
import com.google.common.collect.ImmutableMap
import com.google.common.collect.ImmutableSet
import com.google.common.collect.ImmutableSortedSet

fun <T> emptyImmutableList(): ImmutableList<T> = ImmutableList.of()
fun <T : Any> immutableListOf(item: T): ImmutableList<T> = ImmutableList.of(item)
fun <T : Any> immutableListOf(vararg items: T): ImmutableList<T> = ImmutableList.copyOf(items)
fun <T> Array<T>.toImmutableList(): ImmutableList<T> = ImmutableList.copyOf(this)
fun <T> Iterable<T>.toImmutableList(): ImmutableList<T> = this as? ImmutableList<T> ?: ImmutableList.copyOf(this)

fun <T> emptyImmutableSet(): ImmutableSet<T> = ImmutableSet.of()
fun <T : Any> immutableSetOf(item: T): ImmutableSet<T> = ImmutableSet.of(item)
fun <T : Any> immutableSetOf(vararg items: T): ImmutableSet<T> = ImmutableSet.copyOf(items)
fun <T> Array<T>.toImmutableSet(): ImmutableSet<T> = ImmutableSet.copyOf(this)
fun <T> Iterable<T>.toImmutableSet(): ImmutableSet<T> = this as? ImmutableSet<T> ?: ImmutableSet.copyOf(this)

fun <T : Comparable<T>> emptyImmutableSortedSet(): ImmutableSortedSet<T> = ImmutableSortedSet.of()
fun <T : Comparable<T>> immutableSortedSetOf(item: T): ImmutableSortedSet<T> = ImmutableSortedSet.of(item)
fun <T : Comparable<T>> immutableSortedSetOf(vararg items: T): ImmutableSortedSet<T> = ImmutableSortedSet.copyOf(items)
fun <T : Comparable<T>> Array<out T>.toImmutableSortedSet(): ImmutableSortedSet<T> = ImmutableSortedSet.copyOf(this)
fun <T : Comparable<T>> Iterable<T>.toImmutableSortedSet(): ImmutableSortedSet<T> =
    this as? ImmutableSortedSet<T> ?: ImmutableSortedSet.copyOf(this)

fun <K : Any, V : Any> emptyImmutableMap(): ImmutableMap<K, V> = ImmutableMap.of()
fun <K : Any, V : Any> immutableMapOf(item: Pair<K, V>): ImmutableMap<K, V> = ImmutableMap.of(item.first, item.second)
fun <K : Any, V : Any> immutableMapOf(vararg items: Pair<K, V>): ImmutableMap<K, V> =
    ImmutableMap.copyOf(items.map {
        object : Map.Entry<K, V> {
            override val key = it.first
            override val value = it.second
        }
    })
fun <K:Any, V:Any> Map<K,V>.toImmutableMap(): ImmutableMap<K,V> = ImmutableMap.copyOf(this)
fun <K:Any, V:Any> Iterable<Map.Entry<K,V>>.toImmutableMap(): ImmutableMap<K,V> = ImmutableMap.copyOf(this)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants