Hi there,
I have few feature requests on Kotlin laguage, and I wonder what you think?
- I think arrayList and hashMap are so frequently used types that they should have literals contructs. It will make program shorter and faster to type. Something like these are pretty easier to read and understand:
``
val list = [1,2,3]
val map = {“name” : “Zemian”, “city” : “Orlando”}
compare to current Kotlin syntax:
``
val list = arrayList(1,2,3)
val map = hashMap(“name” to “Zemian”, “city” to “Orlando”)
-
I think “to” function to create a tuple (or multiple assignments now) is a clever way to extend the lang with simple user library, but I tend to prefer a built-in construct for such a frequent used item such as map. I prefer just one symbol charactor rather than two chars. It’s easier to read and type. See above.
-
I think string key hash map is a very frequent used type that it deserves special literal contruct as well. I specially like Groovy’s map that you can use simple words as key without quoting it.
``
val mapOfList = {
list1 : [1,2,3]
list2 : [4,5,6]
list3 : [7,8,9]
}
Compare that to current syntax is much more compact, easier to use, and less typing.
``
val mapOfList = {
“list1” : arrayList(1,2,3)
“list2” : arrayList(4,5,6)
“list3” : arrayList(7,8,9)
}
What’s more important is that this type of String map construct will support DSL programming much more fluently.
-
I think allowing methods to be invoke without parenthesis can save many keystroke typings and could* make source easier to read. I understand in some cases these are problematic, and may cause ugly parser logic in the compiler, but it would give programmers much more flexibility and benefits that I think it’s worth it. Again this feature will make some part of DSL API design much more fluent as well.
-
I don’t understand the reason behind not supporting a “Float” literal construct? I think making user to cast like this is ugly in code:
``
val f = 123.99.toFloat()
Not that I use float type often, but since it’s a support type, and it’s the only type that sticks out like this is pretty ugly to me.
Well that’s all I have for now. I think small things likt these would make programmers more happy in general. What do you think?
Zemian