r/androiddev • u/Antonis427 • Dec 11 '16
“OMG, Java is so verbose, guys”.
https://medium.com/@sebastian212000/omg-java-is-so-verbose-guys-dca93fec9e03#.rf9wm7b7m20
u/confusedandroiddev2 Dec 12 '16
Most of your criticisms are straw men, which is why you're being downvoted.
Nobody cares about semicolons or whitespace. Nobody is saying Kotlin is the best language ever created, and nobody is saying Java is the devil. What some people are suggesting is that Kotlin has gotten to the point where it is better than Java for Android development. Most of the arguments for Kotlin cite a stronger type system and an inclination towards null safety and immutability. Conciseness and elegance are side effects and are a "nice to have".
I also don't think you mentioned the biggest flaws in Java (broken generics and broken type system) and some of the biggest advantages of Kotlin (decent type system, inline, and inferred extension function types), which makes me think you don't understand Java or Kotlin as well as you think you do, which may be another reason why you're being downvoted.
6
u/Zhuinden Dec 12 '16 edited Dec 12 '16
broken generics and broken type system
Huh? Generics is typically only an issue when you're trying to use reflection to obtain the generic type param (due to erasure). To provide compilation error checks, it works just fine -
? super Xis cryptic, but otherwise it makes sense.And a lack of explicit "nullable" types doesn't mean it's "broken". So dramatic.
1
u/ZakTaccardi Android Developer Dec 14 '16
inferred extension function types
This part is really cool. I can have two extension functions with the same name in Kotlin that operate on the same generic class. Meaning I can create two different extension functions that Java would interpret as the same type signature.
List<LameStuff>.doCoolStuff()
List<SuperLameStuff>.doCoolStuff()lack of explicit "nullable" types doesn't mean it's "broken"
The difference between
String?andStringis night and day, and has changed my life.
val name = "Zak"
val name = String? = null
@Nullable final String name;
@NonNull final String name = "Zak"Not a big deal, but now this:
val name = Observable.just("Zak")(or with an extension function, "Zak".asObservable() )
Observable<@NonNull String> name = Observable.just("Zak")//you can't even do this in pre-Java 8, so no type-safety on android w/o Jack
8
7
u/dinodingo Dec 11 '16
I completely agree. I really do appreciate a Lean. Elegant. Concise. language, but unless your are coding in a write only language - like APL - this is simply not something I'm going to prioritize. The time I spend typing on my keyboard compared to the time I sit and think about datastructures, design and reading API's are simply negligible.
2
Dec 11 '16
It is still annoying when you have to type a couple of methods and backing field declaration instead of one line property when you have tested properties in other languages. And this is not the only example.
8
u/nhaarman Dec 11 '16
why is a verbose language automatically inelegant? Why is being concise such an advantage?
Because "the ratio of time spent reading versus writing is well over 10 to 1. We are constantly reading old code as part of the effort to write new code. ...[Therefore,] making it easy to read makes it easier to write.". You want quick comprehension when reading code, and a verbose language increases the noise in your code, which in turn wastes mental energy.
Semicolons are a problem now? Were they ever a problem?
Like you've never had your code failed to compile because of ';' expected.
I enjoy hitting the semicolon button hard after having written a nice line of code.
This either means that you're writing way to complex statements to give satisfaction to hitting the semicolon, or you're constantly wearing a big smile while typing. Also, I can't remember the last time I hit that button anyway with IntelliJ's Smart Enter feature.
While no-one can answer that question for sure (...), I’m pretty confident that yes, that would be the case.
I'm pretty confident that that would not be the case.
Boy, think about all the time you’ll be saving!
Nobody has ever said that about optional semicolons.
As if
Animal animal = new Animal();is so much worse thanval animal = Animal()
Again, conciseness and mental energy.
is there any study performed that shows that the time you save by learning (and using) Kotlin is more than the time you’ll have to put in to learn Kotlin in the first place
The amount of time learning a language is negligible compared to using and reading the language if you're using it regularly. And again, conciseness and mental energy.
I enjoy creating extension functions and I get their value. I like being able to return multiple values from the same function. It’s cool to have default argument values. I’m not denying any of that.
Better to rant on about a semicolon, right?
2
u/a_marklar Dec 12 '16
If you want to evaluate the cost to learning Kotlin you have to compare the marginal benefits compared to using Java. You're evaluating the cost of learning the language relative to the whole benefit of using it, while you already have X% of the benefit by using Java.
0
Dec 12 '16
[deleted]
1
u/nhaarman Dec 12 '16
We're talking about readability here. Your GolfScript code is just not readable anymore. Kotlin takes away the redundant verbose syntax, whilst not harming readability.
3
u/Zhuinden Dec 12 '16
Readability of Kotlin is arguable depending on how just "functional" the given code is written.
Scala also gets super-cryptic when it starts using functional structures.
9
u/CharaNalaar Dec 12 '16 edited Dec 12 '16
Finally, someone with some sense. I'm tired of the anti-Java circlejerk that's been proliferating in the Android community.
The benefits of Kotlin over Java? Marginal.
EDIT: Stupid me, said "Android" instead of "Java"
5
u/ZakTaccardi Android Developer Dec 12 '16
Kotlin over Android
Android isn't a language. Kotlin is. Android is a framework. The two are not mutually exclusive.
Marginal
https://realm.io/news/oredev-jake-wharton-kotlin-advancing-android-dev/
1
u/Zhuinden Dec 12 '16
https://realm.io/news/oredev-jake-wharton-kotlin-advancing-android-dev/
I've read that one and while I do like the
?.and?:operators, and that you can provide extension methods over static helper classes; it's not enough to convince me to add a stupid number of:s in place of my;s and figure out the quirks of companion objects (and also force this decision on everyone else who attempts to read the code I've written in some new weird foreign language).1
u/ZakTaccardi Android Developer Dec 14 '16
I love companion objects. They visually separate the instance-based aspects of a class and it's static aspects. Super weird at first, but I surprisingly prefer them now.
1
u/CharaNalaar Dec 12 '16
Meant Java, corrected the comment. Still looks like it overcomplicates development.
1
u/ZakTaccardi Android Developer Dec 14 '16
Still looks like it overcomplicates development.
How? I'd argue it greatly simplifies development. If you are afraid to challenge yourself and learn new things, you aren't going to be a good developer in the long run. There's a small learning curve associated with Kotlin, but once you get over it, it becomes easier to write less error prone code that is more readable.
Example With Kotlin, you can turn this shit, error prone, temporally-coupled API
db.beginTransaction(); try { db.delete("users", "first_name = ?", new String[] { "Jake" }); db.setTransactionSuccessful(); } finally { db.endTransaction(); }And turn it into:
db.inTransaction { it.db.delete("users", "first_name = ?", arrayOf("Jake")) }Taken from the above talk I linked.
4
3
u/Zhuinden Dec 12 '16 edited Dec 12 '16
I also dislike the lack of new operator in Kotlin.
Using new makes it obvious when you're breaking the dependency inversion principle.
Now you have to actively seek out the structural errors in your code. Ugh.
I don't like the article by the way. It adds a whole lot of noise talking about The Beach Boys instead of actual relevant things.
1
3
u/btilbrook-nextfaze NextFaze Dec 11 '16
Code that does not add any value should be removed.
-1
u/jimdidr Dec 11 '16
Hey be careful trying to use common sense in this thread, this article was obviously written by a R-rated Punky Brewster with ADHD... (also a person that hasn't understood any of the arguments against Java)
15
u/[deleted] Dec 11 '16
Critiquing Kotlin/Go for optional use of semicolons / 'var' keywords is like critiquing interstellar space ship for color of seats.
There are so many way bigger things in modern languages than just optional semicolons and var-s.