DEV Community


Discussion on: Kotlin Vs. Java

khmarbaise profile image
Karl Heinz Marbaise

Based on your post I can see some parts are not really accurate. First Java has 25 years of history.

Apart from that I've seen the example of switch/case vs. expressions in Kotlin. In JDK 13 this is available in Java as well.

Based on your point about data classes which are available with JDK 14 (called records) which exactly do that.

You have created a Java with everything implemented getters/setters .. You usually decide what you like to have either an immutable data class (having only setters; yes you have to write hashCode/equals but that can be handled via Lombok (just an annotation) or just a few keystrokes in your IDE).. (or with records).

About the threads I see things on the way like fibers in Java which are great improvements vs. usual threads. Coming in JDK16 on march not far away. Apart from that it looks like you are referencing here Android and not JVM in general? Maybe I misunderstand a thing here.

The interesting part about: "Null Safety"

Null References generated NullPointerException, requiring you to invest your valuable time in spotting it in the huge codebase.

Yes of course, cause you hadn't have valuable tests to spot such things before ...(using unit tests; mutation testing etc.) also helpful code reviews / pair programming that prevents many of such things.

Kotlin relieves you from this pain, providing you with the null type in the code which you can easily declare when required.

I can say that good designed code using tests etc. the null type or the absent of null would not change a thing. The problem is usually bad designed not really tested code etc. It's not based on the language.

You can always make mistake in any language.

What you have mentioned about a function in Kotlin:

A function in a Kotlin program, with a Float parameter, cannot be called on Int value, but only on Float value.

This sentence implies (based on the parts before) that it is possible to have that in Java which is not correct. That will fail in Java as well.

Some words about the "Popularity" in your article.
In your original article you have referenced the statistics on Stackoverflow by using the title "Kotlin Vs Java Popularity: Most Loved Programming Languages 2019"
but the original title on Stackoverflow: "Most Loved, Dreaded, and Wanted Languages"