4 ms·
I love all the sugar of Kotlin, but there is one thing I miss, and it is the indexing of arrays of Python when pulling out part of an array.
by surfsvammel 4y ago
I love all the sugar of Kotlin, but there is one thing I miss, and it is the indexing of arrays of Python when pulling out part of an array.
- amalgamated_inc 4y agoKotlin is so close on so many things, but then keeps messing up. arrayOf(1, 2, 3) - why not [1,2,3]? emptyArray() - why not []? mapOf("key" to "value") - why not {key => value}? These are all solved problems. Why would they make up some harshly suboptimal syntax?
- kaba0 4y agoI am not that familiar with Kotlin, but these seems better than the syntax primitives from a language design perspective (I greatly recommend the “Growing a language” presentation done by Guy Steele), these are ordinary functions that are well-known from other parts of the language, not an added “hack” that has a one-off use. If you were to use a concurrent hashmap implementation you no no longer can use the syntactic sugar, and writing against an implementation is quite common in Java (which plays quite a big role in the design of Kotlin), e.g. having a List in the interface, instead of ArrayList.
- amalgamated_inc 4y agoInteresting, I think the exact opposite :)
- dima_vm 4y ago`{key => value}` it should be mutableMapOf() just as well. Same for array.
- switch007 4y agoComing to Kotlin from Python, these always get on my nerves. My brain hasn't adjusted to needing to call a function. And 'X to Y' just doesn't click for me. I guess I'll get used to it eventually
- still_grokking 4y agoBecause there are more than three collection types (Sets, Arrays, Maps) in rich static languages. The ugly Kotlin syntax is of course just there to look different to Scala, where you would have: Array(1, 2, 3) Array.empty Map("key" -> "value")