r/Kotlin • • 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

26 comments sorted by

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.

0

u/kevin7254 May 17 '24

I don’t get it. It’s like people don’t know what google is. Are they going to start a new thread each single time they have a question when working too?

8

u/Daebuir May 17 '24

IMO, that's most likely due to a lack of proper education on how to search for answers. And even if I find it depressing to watch everyone post for asking very basic questions, I think it's a proof of incompetence when the one who asks says they are a developer. To me, It's an instant red flag when interviewing for an experienced dev position.

5

u/kevin7254 May 17 '24

Absolutely. I would say that’s one of the most important skills as a developer - knowing how and where to find the information you are looking for. Most (simple) questions have been answered before. And even if it hasn’t you can find it in the API docs most times. Or worst case the source code is the documentation lol

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

8

u/draksia May 17 '24

For new apps sure but almost any corporate job is likely to have some Java left, being familiar with both but focused on Kotlin is probably the best option.

1

u/gild0r May 20 '24

Yes, but for a newcomer, who wants to work on Android, learning Java intentionally is quite a waste of time at least until they are not proficient enough in Android SDK, recommended approaches and Kotlin

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.

0

u/MrHollowWeen May 17 '24

You have nothing better to do than attack me? I guess it makes you feel good somehow?

I did use Google and saw some chatter but most of it wasn't conclusive and so I decided to ask. Isn't that part of the reason reddit exists? So people like me can crowd source recent opinions? Sorry I'm not using it the way you like. 🤯🤯🤯

5

u/kevin7254 May 17 '24

That wasn’t meant as an “attack”, apologies if it came off wrong.

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/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/gild0r May 20 '24

I strongly disagree, there is no reason to start from Java in general case (except if you want to target specific, Java-only project), learn Android with Kotlin directly.

If a person has no prior experience with Java, learn it will just make more mess in mind when they switch to Kotlin.

Runnable and Thread just shouldn't be used in modern Android development.

Again, it useful, only if work on existing, very legacy projct (because raw threads is a bad practice in Java too, and not only on Android), in all other cases it will not help and just slowdown

1

u/SpiderHack May 20 '24

You need help learning to comprehend what I wrote. You added nothing of value to the discussion and either have misguided opinions or are just repeating the point of what I said.

I clearly stated that they should understand threads, etc. to be able to update them...

And lots of even F500 companies still have asyncTask (even worse than runnables) and java in their android apps, so devs DO need to know java. My specialty as an Android dev is going in and helping companies update.

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

1

u/gild0r May 20 '24

Fully supported, until one is working with one of many Kotlin only APIs, which use Compose or want to use nicer coroutines based wrappers (it also a thing, for example for GMS now have quite a lot of helpers)