🌐
Reddit
reddit.com › r/java › can i get some reasons to use java instead of kotlin?
r/java on Reddit: Can I get some reasons to use Java instead of Kotlin?
May 16, 2021 -

I'm thinking about using Kotlin + Spring Boot for my next project, but the level of love for Kotlin and bashing on Java makes me feel a culty vibe. I'd just like to hear some counter points.

Top answer
1 of 38
691
Kotlin is a lot more 'proprietary'. For example, quite a few details about how kotlinc works internally is managed by having kotlin-genned class files have a @Metadata annotation that contain a binary blob (a byte array, legal in annotations) with data that is, as far as I know, not according to any publically available spec. There are also various hardcoded types. This is all quite pragmatic, but it also means that without IDEA, kotlin dies immediately. Pragmatically speaking, a minor niggle. But perhaps you find this lack of openness more important than 'minor niggle'. Kotlin seems to be marketed (both by the community and idea) as java with some minor warts removed. But, what does that mean? Is kotlin supposed to remain 'extremely easy to pick up if you already know java' and 'so close to it, you can interop java and kotlin code with relatively little headache' for the foreseeable future (in which case I foresee some problems I will explain below), or was that mostly just a bootstrap scenario; a way to get a bunch of existing java programmers on board quickly, and give them the ability to transfer their codebase from java to kotlin step by step (by using the interop / double-compile feature)? If that's what it is, then I too foresee some issues in the future. I get the feeling that kotlin folks sort of think it is both, but they are mutually exclusive, so that makes no sense. If you ask someone more familiar with kotlin than I am to explain what kotlin is and/or why the following two arguments do not apply or are properly mitigated, make sure you first establish with them what kotlin's supposed to be. If kotlin is supposed to be 'java but better' forever That's a real problem. I can best explain it using a new feature. All of kotlin's features fall in one of 3 categories: It is the kotlin take on a java feature that existed when the kotlin take was designed. Therefore, the kotlin variant takes into account what's familiar to java programmers and either follows it closely, or if it deviates, it did so for presumably good reasons (switching type and name around and making semis optional don't strike me as good reasons, but this post is long enough as is, and there's a lot of 'personal preference' peppered into that one, so I'll leave that one out of this for now). It is the kotlin take on a feature that java straight up just does not have and still does not have. They've clearly gone their own way and decided to add it because it's important. The problem category: It used to be like the second category (feature java doesn't have), but java has it now. If kotlin is very very lucky, the way java does it, and the way kotlin does it, are similar enough that it all continues to make sense (the learning curve for a java coder to switch to kotlin is not dampened by this), for example if the java impl and the kotlin impl closely align, that's fine. But what if they don't? Here's the point: Over time, more and more kotlin features are of the third category, and this means that kotlin's 'java but better' take is doomed. Here's an example: instanceof pattern matching. This feature did not exist, and wasn't even on the radar (no JEP, no public posts on e.g. amber-dev@openjdk.net ) when kotlin was released. The problem it attempts to solve is that you sometimes want to first check if some expression is instanceof some type, and then, if it is, operate on that data, using the fact that it is that instance. In original java (up to java 14), it looks like: if (x instanceof String) { String y = (String) x; System.out.println(y.toLowerCase()); } in kotlin it looks roughly like: if (x instanceof String) { // in kotlin, x is now assumed to be a string! System.out.println(x.toLowerCase()); } But in java16+, it looks like: if (x instanceof String y) { System.out.println(y.toLowerCase()); } Now, both java and kotlin cater to this use case, they cater to it in a different way, and I'm pretty sure that if I could smack a giant reset button and design kotlin all over again and release it today into public beta, then kotlin would have followed in java's shoes. Especially considering that the java version is in many ways far more powerful than kotlins: You can do more than just 'check type' with this syntax (you can also 'deconstruct' value types), you don't NEED a block, as in, this works too: if (!(x instanceof String y)) return; System.out.println(y.toLowerCase()); and in general the next few releases of java are expanding on this principle, adding lots of pattern matching. Kotlin now has to make a choice: Break everything, kill the old way it works, and follow in java's footsteps. This is disastrous (and extremely unlikely to occur). It would break everyone's code, and it means kotlin is permanently dragged down considerably, as this won't be the last time kotlin clashes with some new java feature. Surely you wouldn't want a language that breaks the world every year or two. Just stick with the kotlin style. That means the argument of 'it is easy to transition from java to kotlin' has gotten a little weaker, and every new java feature released will weaken it more. Kotlin keeps what it had, but also adds this new syntax. That sounds great, but it means kotlin gains feature cruft twice as fast as java does, and thus over time kotlin will become the bloated bizarro mess of too-many-ways-to-do-the-same-thing, inflating learning curves for no benefit. Some more intellingent but convoluted solution, such as keeping both but setting up a deprecating scheme for the 'old' way. This still means that kotlin is permanently in java's shadow and cannot possibly get out of it. None of these 4 options seem all that good to me. Which gets us to what I think kotlin is going to do, and the one that seems the least bad: Option 2 - start parting ways with java syntax. That leads us to: That like-java thing was just a bootstrap solution That means the clock is now ticking. Java development is not sitting still at all, so in a year or 3, the gap between kotlin and java is going to be wide enough that kotlin perhaps no longer feels like 'just, java, with a few warts removed'. It'll really feel like something completely different. That's fine, of course, but the success rate of new languages is abysmal. Scala is pretty much dead (in the sense that it got a bunch of hype, twitter switched over to it, held a ton of fun meets for devs, and... scala now has fewer users than back then, going by admittedly known-inprecise measurement tools such as TIOBE, but, you tell me, do you feel scala is really picking up steam)? - Fan/Fantom seems to have gone absolutely nowhere, groovy is dead enough that e.g. gradle is trying to diversify away from it, jruby and jython have pretty much come and gone (again in the sense that they don't seem to have caught fire). That's no proof that a new language is doomed perse. It's just that this is the default position. Right now kotlin seems to be having its moment in the sun, but it'll get harder as the step to kotlin from java gets harder and harder. It'll have to stand on its own and can no longer claim all the advantages java and its ecosystem have by default. The implementation of e.g. instanceof in java vs. kotlin is already highlighting why I, personally, think kotlin is probably not going to be better than java: Just about every feature that java has released, and is in the process of releasing (as in, active JEPs and active discussions on the mailing lists) seems vastly more intelligently thought out than any of kotlin's features. Java is trying to figure out smart ways to access CPU-native 80-bit registers, how to have complex value types that nevertheless have the performance and memory benefits of primitives, and a whole new programming paradigm by way of pattern matching.
2 of 38
124
.
🌐
Reddit
reddit.com › r/kotlin › latest java vs kotlin?
r/Kotlin on Reddit: Latest java vs Kotlin?
November 6, 2022 -

Hi everyone, I've been searching the last features in java and it seems that Kotlin has become so popular and it has made Java improve. So, what do you think about using kotlin for backend? What do you think about the last features implemented in java 19? Well everything from java 8 until java 19.

I have the feeling that everywhere people are saying that you should learn Kotlin because is going to replace Java, but I am not sure if this is right. Also because as I said I feel that java is picking up features from kotlin and even improving them. What Kotlin has to offer? Besides readability as I heard.

Ps: I don't mind learning a new jvm language, but I would like to know your opinions :)

🌐
Reddit
reddit.com › r/kotlin › java versus kotlin - personal experiences
r/Kotlin on Reddit: Java versus Kotlin - personal experiences
December 24, 2021 - Great for teaching people to code from square one, great for enforcing OOP (if you like it, I don't), great for application stability because the language has very little magic to it. ... I'm not a fanboy but Kotlin is better right now (except ...
🌐
Reddit
reddit.com › r › learnprogramming › comments › src6bl › kotlin_of_java_2022
r/learnprogramming - Kotlin of Java 2022
February 13, 2022 -

As you all know this will remain a question for several more years. I myself started with Java long before I started with android and thought I could combo them. Then Google said Kotlin will be the way forward. In your opinion should I just dig in and go over to Kotlin in 2022? I got myself a training course on this so I just want to know what all you think before i commit. thanks. I saw the Title was wrong yea English is NOT my first language i tend to spot mistakes well after it goes live.

🌐
Reddit
reddit.com › r/androiddev › do people still use java or has everyone switched to kotlin? i just started learning and am using java. will that be a problem?
r/androiddev on Reddit: Do people still use java or has everyone switched to kotlin? I just started learning and am using java. Will that be a problem?
August 13, 2021 - Android change is fast as of late, but Kotlin and esp Android Studio have been around for some time... ... It's pretty much constant rewriting of code to keep it functioning on latest Android versions. That's not very true. Your Java MVP app from 2015 will still run today just fine.
Find elsewhere
🌐
Reddit
reddit.com › r/kotlin › should i choose kotlin over java for a new project (backend)?
r/Kotlin on Reddit: Should I choose Kotlin over Java for a new project (backend)?
June 17, 2023 -

I don't expect a direct answer to the question in the title; rather I would like to get some thoughts from the comunity.

I always prefer Kotlin when searching for a job, but now I need to choose Java vs Kotlin for a new project, and I have the following concerns:

  1. Hiring. Finding a good Kotlin programmer is harder than finding a Java one, Also I had a negative past experience, my ex-coworkers on a Kotlin project held high positions (Senior, CTO) but the code quality was the worst I've ever seen. Kotlin's cool features seemed to give them ability to write even more shitty code than they been able to write in Java.

  2. Future. Java keeps adding more features, and while it still lags behind Kotlin, it becomes harder to convince Java-dev to try Kotlin. And I've found that Java already has enough to be comfortable.

So Java looks like prefereable option. However, when I wrote several classes using Java, they looked like this:

@AllArgsConstructor // Lombok
@Getter
public class User {
  private final String id;
  private @Nullable String email; // NullAway brings null-checks like in Kotlin
}

I realized that this is actually Kotlin code but with annotations instead of language keyword... Like an ugly version of Kotlin, like what's the point to use the ugly version of Kotlin instead of normal Kotlin?

From this perspective, word "Java" in job description would look like manipulation to attract Java devs.

So this thought brought me here.

🌐
Reddit
reddit.com › r/kotlin › i've blogged about whether you should switch from java to kotlin
r/Kotlin on Reddit: I've blogged about whether you should switch from Java to Kotlin
November 28, 2021 -

A few weeks back I started looking into Android development, after about 11 years of writing desktop applications in Java. Of course, this meant learning about Kotlin, so I went down that rabbit hole as as side-trip.

I've always been a big fan of the new features added to Java since Java 8, and Streams and Lambdas have completely changed my programming style. I didn't realize how kludgy all these new concepts felt in Java until I started learning Kotlin. Woa!

I wanted to capture and share my impressions about how much better Kotlin is than Java while the wonderment was still fresh. So while I'm still a Kotlin neophyte, and barely qualified to talk about it, I think my initial ideas would probably resonate with other experienced Java programmers wondering about taking the plunge.

So, here you go: Kotlin - Should You?

Have a read, if you like, and let me know how much I got wrong.

🌐
Reddit
reddit.com › r/java › how does the java community feel about kotlin?
r/java on Reddit: How does the Java community feel about Kotlin?
March 5, 2022 -

In my organization, we switch between Java and kotlin quite frequently for backend development. We use the spring framework which works quite well with both languages. I wanted to know how the broader Java community felt about kotlin? Personally I love it, however Java is still used so widely so I continue to keep my skills up to date on it.

🌐
Reddit
reddit.com › r/androiddev › java or kotlin for android?
r/androiddev on Reddit: Java or Kotlin for android?
March 18, 2023 -

I have been developing android applications in java for a very long time. It is now just like now in my nature using java. Am I loosing something not using kotlin or will it be worth time giving or java is fine?

I am actually not willing to shift to kotlin and just stay in java, I don't know why?

🌐
Reddit
reddit.com › r/kotlin › kotlin is a much better language than java even with all the new stuff java has added.
r/Kotlin on Reddit: Kotlin is a much better language than Java even with all the new stuff Java has added.
December 11, 2023 -

Many kotlin features just won’t get implemented in Java; if they do, they still won’t be as clean or easy to read.

Someone wrote this list and I agree. Does Java 21 have these features?

  • null-safety

  • extension functions

  • more compact and readable code

  • multiplatform development (here suspend functions are very important for platform independent asynchronous operations)

  • almost everything is an expression

  • more functional style (with proper higher order functions)

  • better stdlib

  • mutable captured variables in lambda expressions

  • top-level functions

  • better type inference

🌐
Reddit
reddit.com › r/kotlin › why would anyone choose java over kotlin?
r/Kotlin on Reddit: Why would anyone choose Java over Kotlin?
August 25, 2024 -

Genuinely curious here, not trying to rage-bait.

Java was my first language, and I'll always have a soft spot for it.

But, as a professional Android developer, I can't think of a single thing that Java does that Kotlin can't do (and more simply)

Honestly want to know what I'm overlooking, because I know it must have is advantages. Otherwise it wouldn't be so popular still.

Can one of you Java-gurus enlighten me on what I'm overlooking? I know it wouldn't be so popular without reason

I'm not talking about legacy code, because that's different. I wanna know why people are still building new projects with Java instead of Kotlin!

🌐
Reddit
reddit.com › r/java › backend java 19 vs kotlin?
r/java on Reddit: Backend Java 19 vs Kotlin?
October 31, 2022 -

Hi, I've been searching the last features in java and it seems that Kotlin has become so popular and it has made Java improve. So, what do you think about using kotlin for backend? What do you think about the last features implemented in java 19?

I have the feeling that everywhere people are saying that you should learn Kotlin because is going to replace Java, but I am not sure if this is right. Also because as I said I feel that java is picking up features from kotlin and even improving them.

🌐
Reddit
old.reddit.com › r › Kotlin › comments › ubseb8 › kotlin_vs_java_performance
Kotlin vs Java performance : Kotlin
reddit.com Kotlin · comments · Want to join? Log in or sign up in seconds. this post was submitted on 25 Apr 2022 · 32 points (92% upvoted) shortlink: Submit a new link · Submit a new text post · joinleave91,529 readers · 27 users here now · a community for 13 years ·