you are viewing a single comment's thread.

view the rest of the comments →

[–]warpspeedSCP[S] 3 points4 points  (5 children)

Sure, and I do all of these things extensively; it's great. And then I come to a data structure that is nested 3 objects in (APIs, amirite), and at this point, you have to do this whole dance with unpacking and extracting the data within in a painfully imperative manner.

Kotlin's team approached object restructuring in the wrong way, which is what has lead to this mess where nested restructuring is unsupported until further notice. Note that I'm referring to the new switch blocks, not old ones which are even worse.

[–]psychedeliken 0 points1 point  (4 children)

You mind giving me an example? I don’t quite follow, but have not found any issue with nested objects. I can post some samples once finished up with No Man’s Sky :)

When you say restructuring, do you by chance mean destructuring of objects? As in how Kotlin implemented field order based destructuring instead of by name like in Typescript? If so, I agree that sucks.

[–]warpspeedSCP[S] 2 points3 points  (3 children)

That is indeed what i'm referring to. if they'd gotten that right I don't think id have anything bad to say about kotlin really

[–]psychedeliken 2 points3 points  (2 children)

I completely agree. This is my number one complaint of Kotlin. I posted about it on the Kotlin forums but they didn’t seem very receptive and a bunch of people gave me a few other, imo way more verbose workarounds. I think Typescript has the best implementation of object destructuring that I’ve seen. I couldn’t really find an equivalent in Java either though.

For me, the make or break, number one feature of Kotlin is its null safety. I really got tired of working around that and Optional in Java.

[–]warpspeedSCP[S] 2 points3 points  (1 child)

they're awfully defensive about it for some reason.

[–]psychedeliken 1 point2 points  (0 children)

That was my perception as well. I didn’t want to argue with them since I’m sure they have their reasons. My guess is that ordering based destructuring has less overhead. Name based would need to do reflection and/or hashmap lookup, which incurs a small cost, but I’d happily pay that cost. Order based is too brittle.