5 ms·
I'm just getting started with Kotlin so can't comment too deeply on its problems but here are a couple things that have already annoyed me. Kotlin is supposed
by guelo 10y ago
I'm just getting started with Kotlin so can't comment too deeply on its problems but here are a couple things that have already annoyed me.
Kotlin is supposed to be less verbose but variable declarations and function signatures can get annoyingly long.
//java
String x;
//kotlin
var x : String?
Also, the whole fad of all new languages putting the type after the name doesn't make sense to me.
Where are the ints?
Object objectThing;
Object someOtherObjectThing;
int thing;
int someOtherThing;
String stringThing;
String someOtherStringThing;
Much harder to find the ints in a long list of Kotlin fields:
var objectThing:Any?
var someOtherObjectThing:Any?
var thing:Int?
var someOtherThing:Int?
var stringThing:String?
var someOtherStringThing:String?
- johnfn 10y agoIn the question about ints, use any alignment editor plugin to align your colons.
- always_good 10y agoI'm not even convinced you should be doing that. I disagree with the idea that the Ints are hard to find in their post. That's just not the hard part of reading code, though it's a good example of a pointless micro-comment-benchmark.
- Jach 10y agoYes, they're easy to find here. They're even easier to find if the IDE supports coloring types. And even then, / or ctrl+f lets you quickly find what you know you're looking for.
- barrkel 10y agoPutting types after the variable is a fad that dates from the 60s - Pascal, and ML after it. Usually the name of something is more important than the type. In dynamically typed languages, the name is all you get, and it's enough for a lot of programmers to be perfectly productive.
- ad-hominem 10y agoIf only there were a convention we could use, to encode type information in the names of variables...
- oblio 10y agoI dunno about you, but I usually go looking for variables (names) and rarely go looking for types. I rarely ask: "where are the ints?". I generally ask: "where are the invoices/urls/files/accounts/... ?".
- guelo 10y agoI came across that annoyance in Android code where there were 30 some View fields of different types, TextView, ImageView etc. It wasn't my code so I didn't know what names had been used but I knew that I wanted to find one of the TextViews. In Java Android code we normally group the fields by type to make them easier to find. But maybe we need a different convention for Kotlin.
- Larrikin 10y agoFor Android UI components specifically I usually just include the type in the name. The types can get a little long but when you need to have and operate on userNameTextView userNameTextInputLayout you end up saving time when looking back
- nostrademons 10y agoNormally you'd initialize the variable at the same time you declare it: // Java String x = new String() // Kotlin val x = String()
- deleted 10y ago[deleted]
- LgWoodenBadger 10y agofrom what I remember from the Scala Coursera course, the types after simplify a lot of the parsing, and also allow for type inference. Types first makes this almost impossible. I probably misremembered quite a bit, but...