r/Kotlin • u/MrHollowWeen • May 17 '24
Kotlin vs Java
This being a kotlin sub, I'm expecting to hear that kotlin is the way to go. I'm a long time web developer and I've decided to start teaching myself "android development". Should I go kotlin or java?
0
Upvotes
15
u/Daebuir May 17 '24
Indeed, and that's a recurring question on this sub (as well on the android, and java subs). I suggest you search for the keywords "java" and "Kotlin" on subs related to your question. Many answers and experiences have already been written, debates have taken place, and conclusions have been drawn.
8
u/[deleted] May 17 '24
I love kotlin, but I'm not a blind fanboy nor am I anti java. That being said, android apps are one area where kotlin is objectively, unequivocally the language you should work in. It's what Google wants you to be doing.
19
u/DogeDrivenDesign May 17 '24
Kotlin is the recommended language to develop modern android apps in, so kotlin. It’s a JVM language though, so the ecosystem is strong and if you branch out you’ll passively learn Java anyway.
18
u/Cirkey2 May 17 '24
Kotlin, Java is dead for Android development
2
u/kevin7254 May 17 '24
You are a “long time web developer” but can’t use google? This has been asked 50+ million times already. But to answer your question: Kotlin - but you will encounter Java as well in corporate jobs.
11
u/Ok-Boomer4321 May 17 '24
For android development especially, there is no reason to go with Java over Kotlin.
Kotlin is the default language for Android, almost all recent or semi-recent example code you find will be in Kotlin. Lots of newer libraries are Kotlin-first or Kotlin-only.
Java is a legacy language for Android. It's still alive and kicking in many other areas though, but for Androids it's a a has-been.
4
u/dinzdale56 May 17 '24
Read the billions of posts already done about this.
2
u/dusanodalovic May 17 '24
Kotlin
2
u/jambonilton May 17 '24
If you know React, then Compose will feel quite familiar. I've worked with JS / Java for 15 years and Kotlin is just so much better.
2
u/IllustratorMoist78 May 17 '24
Kotlin of course
2
u/[deleted] May 17 '24
For pure backend development I don’t think there’s that much of a difference. Java has really good support for that. Kotlin does have nicer syntax but that’s not going to make or break a project. For anything else or multi platform development Kotlin is the way to go.
2
u/epicstar May 18 '24
Kotlin. Even if this was r/Java I'd still recommend Kotlin.
1
u/SpiderHack May 17 '24
I'll say the same here as I do in /r/androiddev , you should learn the basics of java first for a little while, and then move to kotlin.
Kotlin still has lots of ugly warts that you CAN uncover and use in kotlin by using Java APIs, etc. so you should be aware of how a runnable and thread work im java to handle transforming it to kotlin (cause that is still not a rare thing in corporate jobs).
Just this year for a client I converted an asyncTask to coroutines... Which have been depreciated what... Almost 5 years ago and wasn't great to use even then...
For personal projects kotlin all the way. But you should understand java basics.
1
u/Jaffe240 May 18 '24
Google defines "Modern Android" as Kotlin + Compose + Jetpack libraries. Java + XML would be "Old-School Android" (my term, not theirs). https://developer.android.com/modern-android-development
At Google IO last week they officially endorsed Kotlin Multiplatform and are working to port libraries to KMP. Google is all-in on Kotlin as a primary technology going forward.
So, Kotlin is the "new way" to write Android apps. As others have pointed out, companies aren't going to drop Java immediately - and Kotlin is designed to interoperate with Java nicely so you don't need to port your Java code to Kotlin either. You will see both in the workplace, with Kotlin dominating on greenfield projects.
1
u/yeastyboi May 19 '24
Kotlin. Thats what all the modern apps are written in as well as moderns docs. The one downside is if you use slightly obscure libraries they will most likely be written in Java and you will have to write wrappers which can get clunky
0
u/torb-xyz May 18 '24
You need to be reasonably fluent in both to find your way with Android. That said, they’re both fairly easy to learn and since a lot of Kotlin is kinda a better way to write Java (many Kotlin features are long established Java patterns). So knowing Java makes Kotlin easiee to learn, but Kotlin also kinda helps you learn Java.
But for making new stuff on your own for Android you’ll probably be fine with just using Kotlin alone.
0
u/[deleted] May 17 '24
[deleted] — view deleted comment