DEV Community

Cover image for The funny Java vs Kotlin battle
Lemuel Ogbunude
Lemuel Ogbunude

Posted on

The funny Java vs Kotlin battle

Scrolling through Twitter I found this Tweet which I kinda agree with:

I went on to check out the Reddit Post spoken of.

Here is my take on what I saw.

In the Android community, there is this constant battle of Java and Kotlin which, in my opinion, is very unnecessary.

I use both Java and Kotlin and can say that Kotlin is a wonderful language.

But here is the issue, to uplift a language, you do not need to talk down on another. If a tool is solid and stands the test of time, people would adopt it.

Another mistake I see is when people compare Kotlin's current features with Java's past issues.

What do I mean by that?

When people compare Kotlin with Java they, sometimes unknowingly, are comparing Kotlin with Java 7.

In case you are not aware, the latest Java version is Java 12.

The Java used on Android is mainly Java 7 and a little of Java 8. Java 8 features are now being added to Android for developers to make use of.

If you are familiar with Android development you would know that in order to use Java Streams, which was a feature in Java 8 (2014), you would need to be on API level 24 or higher to use it on Android.

For clarity sake, API level 24 is Android Nougat.

Another Java 8 feature (which you can now access on Android) is CompletableFutures which could replace all the lines of your AsyncTask Class with just a few lines of code.

If you have noticed, I haven't spoken of the current Java 12 features. It is possible to see Java 12 code and mistakenly think it is Kotlin, that's how much Java has improved.

I am also a Kotlin fan. If you would like to know more about Kotlin check out the Kotlin in Action ebook.

But being a fan of one language shouldn’t make you an enemy of another.

The common arguments I hear are readability and productivity. If you want to read a great article on why Kotlin does not instantly mean readability and productivity read this article.

Adopting Kotlin does not guarantee you would have happier developers, fewer bugs and skyrocketing profit. In the end, the users/clients might not even know or care about what an If Statement means.

If you are using Java on Android, Awesome!
Also check out RxJava for Android Developers.

If you are using Kotlin, keep it up!

If you wrote the app using C++ and it works fine as expected, great!
If you wrote it using React native, wonderful!
If you wrote it with Flutter, marvellous!

We like shiny new tools. We should also focus on getting the job done and maintainable.

Shorter lines of code (especially when not significant) do not guarantee the project would be delivered faster. Readability is subjective and any statistics on productivity should be based on facts.

Happy coding!

Top comments (21)

Collapse
 
eljayadobe profile image
Eljay-Adobe

Well said! Languages are tools. The tools are either suitable or less-than-suitable for a given problem domain.

Java and Kotlin are both very mature, successful languages, on JVM which is an amazing platform. (And the IDE tools available with the refactoring power is jaw-droppingly wonderful.)

I sort of liken the Java/Kotlin battle like the Java/C# battle. Same story, once again. Java on JVM is successful, with wonderful tools. And C# on .NET is successful, with wonderful tools.

Which tool to use, for which platform, really depends on the problem trying to be solved and for what target audience, and with what kind of deployment model.

Everything in the top 50 of the TIOBE Index charts is easily a winner, as a reflection of the industry.

Collapse
 
lemuelogbunude profile image
Lemuel Ogbunude

I couldn't agree more!

Also, the battle is kinda healthy for the languages to keep up and not slack.

Collapse
 
rcosteira79 profile image
Ricardo Costeira

I completely agree with you. I used Java for a long time, and Kotlin was a breath of fresh air. Especially since we can't use Java 9 and above on Android. However, I had moments where I was solving a given problem in Kotlin and thought "Eh, this would've been easier/more straightforward to do in Java", and that's OK. Both languages have their pros and cons, but ultimately both are means to an end. People seem to easily forget that we could already do amazing stuff with Java, long before Kotlin even existed.

Collapse
 
lemuelogbunude profile image
Lemuel Ogbunude

Exactly. You have spoken the truth.

Collapse
 
croxx5f profile image
croxx

I love Kotlin, and it introduced me to a whole new set of features i could not have dreamed in java(altough java is not lagging behind anymore). But let us not forget that if Kotlin is so great is mostly because Java JVM , libraries and community are great. And Java isnt going anywhere

Collapse
 
_hs_ profile image
HS

It's too much this vs that in software and it's only getting worse lately. Take for example C# it's like Kotlin guys. Just hate the Java all the way and compare previous issues with current features of opposite program. And it's worse on global scale now FP vs OOP. Well in case FP people forgot a lot of things they use are built with OOP style. Although on both sides there are people who start this talk down on "opposite" side in my experience it's usually anti-Java people and FP people who start useless discussions.

Comparing things is extremely useful for learning but why think it's the only approach if you like it? This is kind of getting religiously extreme. Scala is good example how to p**s of everyone. It's useful it provides both FP and OOP and does not exclude something just because some programming ideology think it's bad it lets you make the decision. It should be also with the languages and tech in general. The best programming language/paradigm, framework, OS... is the one that gets the job done (or the one that makes you more money :D )

Collapse
 
dmahely profile image
Doaa Mahely

Kotlin does sound really cool. I personally haven't tried it yet.
When it was decided to do an Android app for our graduation project, my colleague suggested using Kotlin, but I thought we should leverage our knowledge in Java as it was the first language we learned at university and the one we took the most courses in, and it has served us well!

Collapse
 
lemuelogbunude profile image
Lemuel Ogbunude

That's great!

Collapse
 
lankydandev profile image
Dan Newton

I agree with this. I also prefer Kotlin at the moment and get to use it at work but do feel like Java gets pooped on a lot.

It's not that bad I'm fine with it but I definitely would rather use Kotlin over it at the moment.

That said, like you also mentioned. I haven't even tried java 10+ yet. It's getting better but I don't think it's there yet.

Collapse
 
lemuelogbunude profile image
Lemuel Ogbunude • Edited

Yes, Kotlin is really nice.

Unfortunately, as you said, some people talk down on Java more than is needed.

Collapse
 
blessedmedia profile image
Blessedmedia • Edited

Great I develop with kotlin,I will comment that it fantastic nonetheless Java is quite good and has a strong community.The developers of both languages do not need to panic because they similar and easy to switch my advise is that it better to work smart than hard

Collapse
 
lemuelogbunude profile image
Lemuel Ogbunude

Well said!

Collapse
 
jbristow profile image
Jon Bristow

Streams and lambdas are awful in Java 8. Completable Futures are... ok, but way more complicated than coroutines. Java’s type system is way less safe... I don’t need to compare kotlin to 7... 8 is bad enough.

Collapse
 
jmfayard profile image
Jean-Michel πŸ•΅πŸ»β€β™‚οΈ Fayard • Edited

Hello you are right.
Kotlin is great and Java is good.

In fact the thing that made Andorid looks extra bad to me is Android.

And more specifically the way the Android team taught us to do Java.

  • Java 7.5
  • No typesafety anywhere
  • Lots of bad recommendations in the name of performance
  • Enums were supposed to be avoided (remember?)
  • God objects that do everything
  • Poor API designs
  • Poor Android documentation

So Java on Android as taught by Google sucks a lot.

Java itself deserves our praise

Collapse
 
redhoodjt1988 profile image
Jonathan Reeves

Well said sir. I agree. I have been using Java and Kotlin both now for awhile and I have to say that I don't prefer one over the other and of I did I would not speak negatively of the other. It serves no purpose to condemn a language because you use/like/love a different one.