Hey everyone! Can anyone here give me a list of ob...
# announcements
n
Hey everyone! Can anyone here give me a list of objective facts that makes Kotlin better than Java? I’m trying to push Kotlin use at work but I keep running into arguments of people saying “but everyone else uses Java, so why not Java?“. I feel like most people are just afraid of change. Has anyone else dealt with similar situations, and if so, how did you deal with it?
e
Kotlin in simple words is
better
java, it handles nullability well in its type system.
data class
can help you greatly reduces boiler plate code on POJOs. Extension functions can help you get rid of the usual
Util
class, also making those function call more natual to use.
a
Are you an Android developer? If so, "but everyone uses Java" is no longer true. Kotlin is growing very rapidly among the Android community.
👍 1
e
And even "everyone uses Java", it does not stop you from using Kotlin, since they are 100% interoperable.
👍 1
d
I would say that the nicest thing for enterprise is the interop. Yes it has all these nice things - plenty of languages are better than Java - but the cost of switching is so minimal! You don't even need to "switch".
Also as an aside, if you yourself aren't sure of what makes Kotlin better than Java (not necessarily saying that this is the case here) then is there a point pushing for it?
👍 3
a
Interrop is a huge benefit, and a way to slowly introduce Kotlin into your codebase without the risk of rewriting everything and all the regression testing that would require. Also, check out the official Kotlin docs for some more comparisons: https://kotlinlang.org/docs/reference/comparison-to-java.html
n
We do not do Android development at work, however, we have the option of using Kotlin. Apparently, interop and data classes are not good enough for the folks that are stuck in their Java ways. They are looking for objective metrics in how Kotlin is better. For instance, they are saying that a bunch of Kotlin’s features are bad, like Operator overloading and Singletons… They also argue that Kotlin doesn’t add any value of Java, and they go back to their main argument that “everyone uses Java”… This is their current pros/cons list: Pros: - Null safety - Proper function types - String templates Cons: - Custom flow control - Ad hoc extension & Operator overloading - Singletons - Smart casts, encouraging bad polymorphism
Also, they said that readability and reducing boiler plate code is subjective… As you can probably tell, I’m arguing with people that are super stuck in Java land
Fun fact: they think https://kotlinlang.org/docs/reference/comparison-to-java.html is a marketing document 🙂
a
I can see why someone would say that. Even though I disagree with the sentiment, isn't the whole purpose of a "marketing document" is to sell you on why your product is better than the competitors?
reducing boiler plate is not subjective, I can dig up an old gist for you to demonstrate an objectively simpler method because of Kotlin one moment
Methods like
first()
and
firstOrNull()
reduce all the boilerplate of the typical sequential searches you had to write in Java.
and they come out of the box, and not through some apache commons dependency or whatever else people may have used.
d
smart casts encourage bad polymorphism? As opposed to manual casts??
n
@Daniel Tam Apparently so… I totally disagree with that statement, but some people in the office have that view
d
that's okay tell them they can manual cast if they're afraid of letting the compiler do work for them
they can probably even disable the warning that tells them that the cast is unnecessary
hahaha