News for hackers. Stuff that matters.
Re:Java's records, Lombok's data, and Kotlin's data classes by lmm on Saturday May 08, 2021 @12:11AM (#27083786)
Kotlin doesn't have immutable collection types in the standard library (it lets you use a read-only interface but the collection is really still mutable and will be seen as such by any Java code), so if you want actually immutable collections you have to use non-standard collections, and since Kotlin doesn't have typeclasses or implicit conversions it's difficult to interoperate between any non-standard collection library and other Kotlin code.
Re:Java's records, Lombok's data, and Kotlin's data classes by lolinder on Saturday May 08, 2021 @12:52AM (#27083983)
Ah, fair. I've never actually seen that become a problem, but I can see how it would be if I were doing more extensive Java interop.
Re:Java's records, Lombok's data, and Kotlin's data classes by lmm on Sunday May 09, 2021 @01:27AM (#27093475)
Yeah, if all your code and libraries are Kotlin then there's less risk of a collection being mutated under you (though even then, Kotlin gives you no way to write a method that only accepts an immutable collection - you can write a method that accepts a view-only interface, but it will always be possible to pass a mutable collection and mutate it in parallel while that method is running). But of course in that scenario there's also zero benefit from having compatibility with the Java collections.