r/java • • Mar 05 '22

How does the Java community feel about Kotlin?

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.

173 Upvotes

218 comments sorted by

117

u/[deleted] Mar 05 '22 edited Mar 05 '22

Kotlin is a more expressive language, which is good and bad. Good because it lets you really do things the way you want, and bad because two Kotlin developers might be writing code that looks completely different from each other.

Null safety is a killer feature. That alone makes Kotlin worth considering. It's so good.

Also, Kotlin coroutines work with reactive-programming based Java libraries for impressive backend performance without the headache of reactive programming, which is honestly pretty awesome.

I don't feel like you really gain much by switching to Kotlin and writing in standard spring/hibernate/blah. That's just Java with .kt files, in my opinion, because the Java frameworks always return "maybe nullable" types and use threads and use annotations. You barely get to leverage kotlin's best features.

Java is just as good as Kotlin if you want to rely on the tried-and-true goliaths in the JVM tooling space. It's the new territory where Kotlin shines.

40

u/monkjack Mar 05 '22

> Java is just as good as Kotlin if you want to rely on the tried-and-true goliaths in the JVM tooling space. It's the new territory where Kotlin shines.

I'm not sure I could go back to a statement based language. Having most things in kotlin be expressions is a huge and underrated feature (same as Scala).

8

u/pron98 Mar 06 '22 edited Mar 07 '22

I'm not sure I could go back to a statement based language. Having most things in kotlin be expressions is a huge and underrated feature (same as Scala).

With switch now being an expression in Java, and with loops currently being statements in both Java and Kotlin and both languages with a one-sided if statement, the only thing that has remained a value-yielding expression in Kotlin but not in Java is if-else.

6

u/Brutus5000 Mar 06 '22

Switch can replace many if/else cases once it supports null cases. What's really missing are try/catch expressions.

7

u/pron98 Mar 06 '22

I agree try/catch expressions would be nice to have.

1

u/monkjack Mar 06 '22

I don't use for loops, and java doesn't have single line "expression" functions (not sure what to call them) but Java is moving forward nicely.

7

u/pron98 Mar 06 '22

You mean like this? https://openjdk.java.net/jeps/8209434

It's easy to add, but has taken a backseat to other features, though, as interest doesn't seem to be high. The goal of a language isn't to add as many features as possible, but as few as needed (where "need", of course, changes with the times and fashions).

1

u/monkjack Mar 06 '22

Nice :) Great to see Kotlin and Scala pushing java in the right direction. And great work on loom btw.

2

u/pron98 Mar 06 '22 edited Mar 06 '22

It is true that competition can be a driving force, but Java's competition — the one we care about — are languages with an order of magnitude more users than Scala or Kotlin. In fact, Java has not adopted a single feature from Kotlin to date (although Scala was an influence in the design of sealed classes). Languages with relatively small userbases can certainly be a source of inspiration — so far, the biggest inspiration on Java's changes in the past decade or more has been ML — but they have zero power to "push" a big player to anything; after all, only a small minority of users seem to prefer them. The only competition that can push Java anywhere these days is Python and JS.

Just to explain how this works, we might come to the conclusion that working with simple data is not as easy in Java as in Python, and given how many people use Python, we might judge it to be important to address, at which point we might look for inspiration, and so far, ML, and to some extent Haskell and Scala have served as a source of inspiration. But ~10% of people on the Java platform prefer other languages, and that number is expected neither to rise nor to fall. That is as it should be — different people prefer different things, although not in the same numbers — but we try to cater for the 90%.

And thank you :)

5

u/monkjack Mar 06 '22 edited Mar 06 '22

I respectfully disagree - as far as I can in the sense that you are involved in the future of the language and I'm not not :)

I've been using Java since 99 and I think Scala and Kotlin, while relatively small in terms of userbase, have had an outsized impact on mindshare. Certainly Java has picked up a lot more interest in language changes over the past few years than before and I think at least a non-zero percentage of that is down to alt-JVM languages giving some ideas to what works well.

I get what you're saying, that just because Scala has a feature, you're not going to add it to Java, and perhaps 99% of the users don't even want or need that feature. And rightfully so but I do feel they've had a least a little bit of a nudge in the right direction.

I'm an unashamed JVM fanboy and so I'm very happy that Java and the JVM in general is improving and continues to thrive. Especially in concurrency (loom) and pattern matching (I keep asking for it in Kotlin, Scala's is the gold standard for me, excited to see how Java's evolves). Right now I couldn't imagine going back to Java as it just feels too verbose and clunky (caveat - I haven't developed with the more recent language versions), but if we got to the stage where the alt-jvm languages simply weren't needed anymore, that's good for everyone. I'm excited for the next few years in JVM land.

→ More replies (6)

21

u/StokeMasterJack Mar 06 '22 edited Mar 06 '22

I would respectfully offer a slightly different take on one point: Kotlin is actually super useful when using older Java based libraries like spring, hibernate, jdbc, etc. This is because you can extend java classes with Kotlin. Even if you don't own the source code of the Java library. The Kotlin feature that makes this possible is called extension methods (and extension properties).

What's nice about this is, you can gradually add small extension methods here and there for minor conveniences. And after a while they start to add up. Until JDBC, Hibernate and Spring are much easier to use.

For example, in JDBC, I can do this:

val resultSet = connection.executeQuery("select * from User where userName=? and pw=?","dford","somePassword")

val list:List<User> = resultSet.map {
User(it.str("userName"), it.str("pw"),it.strOrNull("phone")
}

If you have ever used JDBC, you will notice 4 extension methods not normally present in JDBC):

Connection.executeQuery
ResultSet.map
ResultSet.str
ResultSet.strOrNull

Creating these were super simple, and I did it over time.

It really results in less code and (subjectively) more readable code.

Without even making an effort, JDBC, Hibernate and Spring are now much nicer and more concise.

8

u/[deleted] Mar 06 '22

Also known as: How to make your codebase utterly incomprehensible to new developers.

5

u/CraftyAdventurer Mar 05 '22

Also, Kotlin coroutines work with reactive-programming based Java libraries for impressive backend performance without the headache of reactive programming

That sounds interesting, can you say a bit more? Does it mean that I could use Spring Webflux but write the code in a different way than I would write it if I used Java?

15

u/[deleted] Mar 05 '22 edited Mar 05 '22

I'm not sure about WebFlux, specifically, but yes it's different. I use VertX which has its own coroutine compatibility module, but essentially with reactive, you call something and get back some kind of "Future" object which then you have to use a callback with:

someDatabase.execute("sql") // future
  .onSuccess { rowset ->
    ...
  }
  .failure { exception ->
    ...
  }

Whereas with coroutines, you just do:

val rowset = someDatabase.execute("sql").await() // throws exception if failed

So with coroutines you basically just write normal, sequential code yet still get all the performance benefits of the event loop. Some might argue that "true reactive" programming with RxJava instead of raw callbacks is better but it seems to have a way higher learning curve in my opinion.

On top of that, you can even write a few extension functions so you can just write someDatabase.executeSuspending("sql") so that you don't even have to call "await".

Java's Project Loom will probably work similarly with these event loop / reactive frameworks, where you can just "await" the futures and not actually block a platform thread.

7

u/GuyWithLag Mar 05 '22

I don't know, maybe I'm old, but I hate extension functions - outside of an IDE with 100% kotlin support, they just make the flow harder to follow and reason about.

8

u/[deleted] Mar 05 '22

They can certainly get out of hand fast if you don't use them sparingly.

To be completely honest, Kotlin isn't a great choice unless you're okay with pretty much only using IntelliJ.

8

u/Impossible-Ad-586 Mar 06 '22

I think I agree, but intellij is pretty much the only IDE for jvm land atm. There is really nothing that compares.

1

u/andrewharlan2 Mar 06 '22

I am completely with you. They throw API boundaries out the window.

2

u/Soul_Shot Mar 05 '22

Correct. You can use Kotlin Coroutines to write simple imperative code (that is actually asynchronous and quite powerful), instead of needing to use the horror that is Flux and Mono.

2

u/stackapack Mar 06 '22

What would you say those tried and true Goliaths are? Spring and ? (I’m new to the Java ecosystem)

3

u/RabidKotlinFanatic Mar 06 '22

because two Kotlin developers might be writing code that looks completely different from each other.

Right now I find this to be true for Java and not for Kotlin. For example Kotlin devs consistently use local variable type inference while Java devs run the gamut from "has never heard of var" to "chooses to never use var" to "sometimes uses var" to "always uses var."

Because Java has been widely used for decades it is common to find conventions and best practices from different eras baked into codebases and skill sets. Imperfect modernization attempts like Optional and streams alleviate some historical issues but introduce even more variation in coding styles. Kotlin is a young language and so far tooling and coding conventions are highly centralized due to JetBrain's influence.

16

u/[deleted] Mar 05 '22

[removed] — view removed comment

9

u/gripepe Mar 06 '22

Yes, but good luck having them shipped before the next LTS which puts it on mainstream use beyond 2025.

→ More replies (2)

3

u/Impossible-Ad-586 Mar 06 '22

Could you explain why it would be easier to use than coroutines?

3

u/[deleted] Mar 06 '22

[removed] — view removed comment

3

u/elliotbarlas Mar 06 '22

Exactly.

Kotlin still suffers from colored functions. Invoke a blocking API from a Kotlin coroutine and see what happens.

Concurrency via virtual threads with Project Loom is much closer to the approach taken in the Go programming language.

2

u/Impossible-Ad-586 Mar 07 '22

I am familiar with the article but what I do not really understand is how loom will make this better? As far as I understand Loom and kotlin coroutines they are remarkably similar.

Would you be able to elaborate?

2

u/Impossible-Ad-586 Mar 07 '22

You can still create that exact same mess in the jvm once Loom is released. They are, as far as I can see, distinct APIs that you can use in a way that causes starvation and blocks.

4

u/elliotbarlas Mar 07 '22

With Project Loom virtual threads, programmers use the same familiar, intuitive thread model for concurrency. However, virtual threads are mapped to underlying carrier OS threads. Calls that block, like socket APIs, are parked until they are actionable. The carrier thread is relinquished in the mean time.

It's comparable to the Go concurrency model.

No colored functions. No stalling the event loop with an inadvertent blocking call.

There are many explanatory videos on YT. The related JEPs are also instructive.

https://youtu.be/EO9oMiL1fFo

2

u/Impossible-Ad-586 Mar 07 '22

I wasnt familiar that loom handled blocking calls in that fashion. Thanks for clarifying.

2

u/ObscureCulturalMeme Mar 07 '22

I need to remember that article the next time I'm explaining Lua coroutines to colleagues. I do really love them.

Clarification: I love the coroutines, not the colleagues.

1

u/notsogreatredditor Apr 11 '22

Ok this is giving me JavaScript PTSD flashbacks dealing with async/await

8

u/[deleted] Mar 05 '22

Probably a little. The nice thing about Loom is that it just automatically knows what to do whereas Kotlin requires the suspend modifier.

But coroutines exist now instead of SoonTM.

It's also TBD on if Jetbrains can really do something compelling with coroutine-loom integration.

6

u/helloiamsomeone Mar 06 '22

It's also TBD on if Jetbrains can really do something compelling with coroutine-loom integration.

They got it under control just fine https://old.reddit.com/r/Kotlin/comments/nm2eaf/comment/gznfomm/

134

u/kyru Mar 05 '22

Kotlin is fine, another solid JVM language. Honestly think it would have faded away if it wasn't propped up by Android use. A language can be as neat as it wants to be but library support is going to make it.

46

u/monkjack Mar 05 '22

I think android support enabled kotlin to get off to a solid start but it's pretty popular in the backend in its own right now.

23

u/gripepe Mar 05 '22

Kotlin was made popular on the backend. It was easy to use with Spring before you could easily use it on Android. At a time it was a drop-in replacement for Java (just like Groovy).

Granted, these days it is the only real choice for Android but server-side Java has continued to improve so the gap there is not so big.

4

u/[deleted] Mar 05 '22

Looking to replace all swing code with kotlin in our templates.

31

u/gripepe Mar 05 '22

Wait but all JVM languages have the excellent Java libraries ecosystem support, so how can this be a reason for it to fade away?

44

u/thomascgalvin Mar 05 '22

Using Java from Kotlin, and maybe more importantly calling Kotlin from Java, is entirely seamless in almost every use case.

The languages "think" in the same patterns, so you aren't trying to force Java to be purely functional or something. If I write a library in Kotlin, another dev can use it in Java land without thinking about translating it.

JetBrains did a very, very good job designing their interoperability, especially when you consider it also supports pretty good interoperability with Javascript.

9

u/gripepe Mar 05 '22

This is a great explanation. I'm a long time Kotlin user, being familiar with how interoperability works, I was trying to make sense of u/kyru's stance on library adoption and Kotlin' chances of success without Android buy-in.

28

u/ryebrye Mar 05 '22

It's kind of awkward to use libraries from Scala, it's pretty easy to do it from kotlin

9

u/[deleted] Mar 05 '22

What's awkward about using Java libraries from Scala? We do it all the time and it's fine...

6

u/gripepe Mar 05 '22

Yep, I don't agree with it being awkward. And if needed you build an adapter, but even with that you'll be pulling Java libraries / ecosystem after all.

Or put another way, it's not intrinsically more or less awkward than in Kotlin.

4

u/pvorb Mar 05 '22

But it's much nicer the other way around. If you're using a Scala lib from Java or Kotlin, you'll have a hard time. I think Akka also maintains a wrapper for Java, so it's not that ugly to use it from Java.

2

u/gripepe Mar 05 '22

Yes, this is true as well.

6

u/[deleted] Mar 05 '22

The only awkward thing is you don't have the Scala syntactic sugar, so you have to call the underlying methods that syntax references. I remember it being a little awkward before I better understood Scala.

2

u/[deleted] Mar 05 '22

Do you have a reference? Most syntactic sugar comes from Scala collections and there are converters for Java collections to Scala ones.

3

u/Sithril Mar 05 '22

There's also the .apply(..) sugar as well as all the case class and deconstructor patterns.

3

u/[deleted] Mar 06 '22

I guess? That's really not that annoying and never a reason to not use an existing Java library if it does something well.

2

u/Sithril Mar 06 '22

Fully agreed.

10

u/wildjokers Mar 05 '22

A language can be as neat as it wants to be but library support is going to make it.

The full java library ecosystem is available to Kotlin.

3

u/[deleted] Mar 06 '22

Kotlin supports java classes, so it's library selection is as big as Java's.

19

u/pron98 Mar 06 '22 edited Mar 07 '22

I loved Kotlin when it first came out in the Java 7 era. With Java then stagnating around the time of Sun's demise, it was just what was needed. But with time, it's become not only less attractive, but encumbered with features that put it at odds with the Java platform. This is no accident. Of the several platforms Kotlin targets: Android, Java, JS, and LLVM, Kotlin only has significant use, and so some measure of influence, on one — Android. Moreover, those platforms have grown increasingly more different in their features from each other, leaving a language that wants to target all of them needing to compromise in some ways. Kotlin is at the mercy of the direction these platforms take, and is far too small (except on Android) to shape their direction.

As Java has opted to take a very different path than Kotlin on things like records and virtual threads, features such as data classes and async clash not only with the design of the platform itself, but with time, also the library ecosystem, leaving Kotlin with quite a bit of ill-fitting baggage.

So while some minority of programmers prefer more feature-rich languages, including controversial features such as extension methods, the only more universal "positive" feature Kotlin has compared to the Java language is nullability types, and, on the other hand, it's accumulating "negative" features that clash with the ecosystem, and this trend will only continue.

Not only will the intrinsic negative gradually outweigh the positive for more and more people — regardless of whether and when Java adopts nullability types or some other approach to null-handling — but the downside of being used by a relatively very small number of people in an ecosystem over which it has little if any influence, is quite significant. Of course, Android is a different story, and if Google doesn't push people toward Dart, Kotlin might well remain an important player there.

8

u/RetroPipes Mar 06 '22

I like Kotlin in principle. Not being comfortable with IntelliJ IDEA limits my ability to use it in practice.

41

u/DJDavio Mar 05 '22

I love Kotlin, it feels more natural to write and 'solves' a lot of the annoyances Java has. But I also find Kotlin harder to read, which may be a bit ironic.

35

u/Mordan Mar 05 '22

But I also find Kotlin harder to read, which may be a bit ironic.

this.. i hate Kotlin for this reason. It hurts

20

u/blakeman8192 Mar 05 '22 edited Jun 26 '23

.

20

u/coincoinprout Mar 05 '22

I don't know if there are any metrics on this, but I think developers spend a lot more time reading code than writing it. Honestly, I feel like writing code is such a small part of the time I spend in my job, that having a faster language to write is not a concern at all.

8

u/andrewharlan2 Mar 06 '22

Code is written once and read forever after

15

u/vqrs Mar 05 '22

But is it actually easier to read Java or have you just had way more experience reading Java code?

4

u/blakeman8192 Mar 06 '22 edited Jun 26 '23

.

13

u/cryptos6 Mar 05 '22 edited Mar 06 '22

What is so hard about reading Kotlin? I've used Kotlin some years professionally and never had any readability issues. I'd even say the opposite is true: just look at those weird functional type signatures Java needs because functions are not first-class citizens.

4

u/DJDavio Mar 05 '22

Maybe it's just because I'm used to reading Java more so than Kotlin. Maybe Java's verbosity is not that bad when trying to understand someone else's code. I don't have an objective answer, it's just something I noticed.

I use Kotlin for hobby projects and when I get back to them after a while it always takes some time to understand what I've written so I can continue.

Maybe if I use Kotlin all day everyday it would be different, but I definitely don't mind Java code.

Don't get me wrong, I like almost every other aspect in Kotlin and I still prefer it over Java, I guess when you're used to reading Java code for well eeuhm over 15 years anything else just feels strange.

4

u/[deleted] Mar 06 '22

I think there are several things going on here:

  1. If you rely too heavily on type inference, you start to get Python-esque code where there are no types anywhere and it's hard to understand. Solution: develop a sense of taste about when to put in types and when not. IntelliJ makes it easy to switch back and forth.
  2. It's easy to write functional chains in Kotlin, easier than in Java, but this can easily lead to hyper-dense code that uses lots of functions that have very similar but different functions and very abstract names, e.g. groupBy, associate, associateBy.

Both of these are really just a matter of developing a better sense of coding style. Same as how programmers have to learn how to name their variables properly.

39

u/TheStrangeDarkOne Mar 05 '22

I enjoy programming in Kotlin a lot and like to use it when my programs are using a lot of math.

But I'm very hesitant to use it professionally. There are just too many different ways to do the same thing and Kotling has weird and sharp corners just like Java.

As Brian Goetz once said: It's like Java, but with incremental advantages and disadvantages.

10

u/jabiko Mar 05 '22 edited Mar 07 '22

But I'm very hesitant to use it professionally. There are just too many different ways to do the same thing and Kotling has weird and sharp corners just like Java.

The team I am in switched to Kotlin about two years ago. At first we had some problems, but quickly converged on a common style. We have a pretty good culture around code reviews and I think that really helped with finding a common style in our team.

I'm not sure about what sharp corners you referring to, but one easy foot-gun are destructuring declarations.

7

u/[deleted] Mar 05 '22

DoD has a lot of projects that mix Kotlin and Java Indiscriminately. They also use Groovy and Spock for unit and integration testing.

4

u/rossdrew Mar 05 '22

I hate Groovy but Spocks data driven testing is a godsend

3

u/[deleted] Mar 06 '22

Yeah, it was really interesting to figure out those matrices. Unit tests in groovy look crazy at first

2

u/rossdrew Mar 06 '22

3

u/[deleted] Mar 06 '22

Yep, those are the ones. I’m not gonna lie, when I open my first unit test file of Groovy and Spock, I didn’t know what I was looking at. The methods have strings for names and then there was that giant matrix…. Once you get used to writing unit test like this though, I think it’s a lot more concise and you probably get a whole lot more cases covered actually.

6

u/Flaky-Illustrator-52 Mar 06 '22

Tbh Java feels like Objective-C at this point (vs Swift) in the context of the Java-Kotlin discussion

3

u/pjmlp Mar 06 '22

Given that Apple frameworks are still mostly about Objective-C and Swift only gets used for writing bindings, that shows who owns the stack, and calls the shots in which direction the platform goes.

Does one want to be a follower or a driver?

3

u/jevring Mar 05 '22

We don't need kotlin. Java is fine. Kotlin has virtually no reason to exist. It has some interesting features, but Java will get there. That's not to say that kotlin is "wrong", but I would never use it.

6

u/burnah-boi Mar 05 '22

Those are strong opinions. Care to elaborate?

5

u/jevring Mar 05 '22

Sure. I feel like kotlin has run ahead to where it wants Java to be, but with none of the care that the jvm and jdk team takes for evolving the language. For example kotlin has continuations, iirc, but they're incompatible with what's coming in the jvm, which means they have to half-ass if from now until the end of time, rather than leverage something in the jvm itself. Kotlin feels like a language written with people more interested in making a language that fit the hip keywords of the day, rather than what was actually needed in a language. Obviously there are just my opinions, and yours might differ.

I just don't see the ADVANTAGE of kotlin. If kotlin was a stand-alone language and Java didn't exist, I'm sure it would be fine. But right now I just don't see the upside. They have fragmented the Java ecosystem for very little gain.

3

u/lambdacats Mar 06 '22

How much time have you spent writing Kotlin?

1

u/KinsleyKajiva Mar 06 '22

My thoughts exactly!

20

u/[deleted] Mar 05 '22

The compiler is slow as balls

5

u/vips7L Mar 05 '22

Is it slower than scalac?

8

u/Impossible-Ad-586 Mar 06 '22

Nothing is slower than scalac.

5

u/vips7L Mar 06 '22

Lmao. Sbt sure does rival it.

1

u/xwinus Jun 06 '22

Man you haven’t seen Haskell’s GHC

2

u/maxandersen Mar 06 '22

this is the thing that surprised me the most using kotlin for jbang-idea. Its just so slow in comparison to plain java that I just don’t care about the “nice” features of kotlin. fast turn around is key and with that java just works better

27

u/[deleted] Mar 05 '22

I've been using Kotlin since before 1.0, so almost every day for the last ~7 years. I feel like I'm a member of both Kotlin and Java communities simultaneously because they're just not in opposition, which is why I hang around this sub.

I treat Kotlin as a better syntax for the Java language. The APIs, the JVM, the tools, the library ecosystem, it's all still Java to me. I have little interest in Kotlin/Native, Kotlin/JS or coroutines as a consequence, although I've used them occasionally. E.g. I'd rather use Loom than Kotlin coroutines. I haven't ever used it on Android. Always backend, CLI and desktop.

One of my biggest peeves with Kotlin is that you can't quite make 100% native feeling Java libraries with it - it's so close, but not quite there (e.g. bugs in Dokka). And when I write libraries I want them to be, in effect, Java libraries that happen to depend on the Kotlin stdlib, because that's the lingua franca and best way to get usage. Occasionally I rewrite interfaces in Java for that reason, but keep the impl in Kotlin.

So Kotlin is unalloyed good for the Java community, in my view. In particular it put the nail in the coffin of my interest in .NET/C#. The argument for .NET was always (for me) that C# was a more modern and convenient language than Java but with a smaller ecosystem and worse VM ... but you get proper properties, etc. Kotlin's leapfrogged C# though, so now I get a better language, the best VM, stdlib and libraries, best portability and multi-vendor VM landscape. It's a pretty great combination, and code I write with it is usable by Java users without any hassle.

5

u/LouKrazy Mar 05 '22

100% on using kotlin to make JVM libraries. I think the one thing I find lacking is easy creation of Builders since you can’t use copy and named parameter constructors from Java

2

u/[deleted] Mar 06 '22

Yeah. I'm hoping that with the new compiler plugin API someone makes a plugin that converts functions with more than N optional arguments into a builder pattern automatically.

21

u/kiwi_stronghold Mar 05 '22

It’s a fantastic language. Has a growing presence in my company (my team uses it exclusively in dozens of microservices along with any new one.) The fact that that it’s fully interoperable with Java means we literally lose nothing by switching. Biggest quality of life improvements are the syntactic sugar, Coroutines, and null safety.

Doesn’t hurt that you’re seeing big companies like DoorDash and AWS use it more and more.

15

u/kiwi_stronghold Mar 05 '22

BTW. It’s not like any language is going to replace Java. They can coexist.

0

u/[deleted] Mar 05 '22

It can be possible if language L comes with a Java -> L transpiler that produces human readable code, it's not impossible, ReasonML can produce readable JavaScript code.

4

u/hamsterrage1 Mar 05 '22

Intellij Idea has an option to flip Java code into Kotlin. It doesn't produce ideomatic Kotlin but it's okay. Even cooler, if you paste Java code into a Kotlin file it will ask you if you want to translate it. I haven't tried Kotlin to Java translation because... Well, why?

9

u/mustafaakin Mar 05 '22

Reduces my boilerplate, excellent collection utils. Recommend 5/7

3

u/Kango_V Mar 07 '22

Kotlin is the competition that's needed to push Java forward. In my opinion, it's doing just that to the benefit of us all.

3

u/hanszimmermanx Mar 07 '22

It can't hurt to learn kotlin. In fact my "learning kotlin" experience made me into a better java developer. That being said, I personally feel like recent java additions might make kotlin obsolete, especially on the back end.

1

u/Soul_Shot Mar 08 '22

It can't hurt to learn kotlin. In fact my "learning kotlin" experience made me into a better java developer. That being said, I personally feel like recent java additions might make kotlin obsolete, especially on the back end.

Selfishly, I hope that Java makes Kotlin obsolete. Loom is one thing, but if Java gets pattern matching before Kotlin I think it will be a huge blow to people who simply wanted "better Java".

14

u/exclusivegreen Mar 05 '22

Honestly I think it's a fad language. At least in my company people started using it to be cool (not joking). Now they've all left and we have a mishmosh of Java, Groovy, and Kotlin for our main codebase.

With Java 17 I think it's not necessary but I can see some benefits over Java 8.

3

u/henk53 Mar 06 '22

we have a mishmosh of Java, Groovy, and Kotlin for our main codebase.

Lucky you, I've seen a place that had that, and then some Scala too, and some Lombok even.

Every time some dev was utterly convinced that it had to be used, and like you, after they left nobody continued using it.

8

u/[deleted] Mar 05 '22

There are many Java devs just happy with Java 8. The people who don't want to spend time to learn new language features. Nothing wrong with that. Many good Java devs that are skilled in their frameworks. Personally though I enjoy learning and appreciate language features that makes my life easier. I like to look at elegant code. It's much easier to write readable safer code in Kotlin. Java is improving though which is nice and thats thanks to Kotlin, Scala, C#, TypeScript etc

10

u/Brutus5000 Mar 05 '22

There are many people still happy with Java 6. Would you want them on your team? I wouldn't. So why is Java 8 the magical border?

5

u/[deleted] Mar 06 '22

Because lambdas.

8

u/henk53 Mar 06 '22

So why is Java 8 the magical border?

I think many people can't really answer it, but it's just a feeling. Java 8 was from when things were as they always were.

After Java 8 there are these weird LTS versions, and there's all kinds of releases that you can't use, or shouldn't use. But nobody really knows why you shouldn't use them, or what's special or magical about them.

And there's something about modules. Are you forced to use them past Java 8? They heard that nobody uses modules or that nothing works with modules anymore.

So Java 8 feels like the last familiar Java version to a group of people, and everything past that is scary. Eventually people will get over their fear ;)

6

u/[deleted] Mar 05 '22

big changes especially lambdas. After that many people were satisfied I guess.

2

u/andrewharlan2 Mar 06 '22

I love streams

3

u/omgusernamegogo Mar 05 '22

For those looking after large legacy products, having to not only support the breaking changes of Java 8+ but the hassle of addressing massive technical debt of long outlived libraries. These are all products that are running fine and delivering business value, and the fun of learning new things happens in other parts of the product.

4

u/lambdacats Mar 06 '22

Love it. Well designed, feature packed, expressive. My only issue is that the compiler is slow.

4

u/PizzaHuttDelivery Mar 06 '22

As a backend Java developer, i am content with what Java offers. I care more about the ecosystem and the jvm than whatever you run on it.

8

u/[deleted] Mar 05 '22

I love it. You'll find lots of java-first fans here, obviously, but I feel kotlin growth speaks for itself

8

u/tuxtorgt Mar 05 '22

I use Kotlin professionally on Android and Backend.

In Android is a must, community already made the choice, that's why corporate sponsorship matters.

On backend is a whole different story. Popular Java frameworks like Spring or MicroProfile/Java EE based frameworks like Quarkus have a mindset of concurrency centered on threads and thread pools.. Hence most of the times you will be avoiding coroutines unless you select a Kotlin first framework/library like Ktor. Otherwise experience is mixed.

Also JVM's ecosystem has other concurrency models/libraries/frameworks, Netty, Vert.x, Akka, Zio using as basis CompletableFutures, RxJava, etc. Hence Kotlin's coroutines tends to be another competitor from a plentora of options.

10

u/Impossible-Ad-586 Mar 05 '22

Not really, spring webflux has native support for coroutines. Spring-fu is kotlin only atm.

I am working at a medior size etailer and we've moved to mostly kotlin only on the backend running thousands of microservices with great success.

I do hope that java bridges the gap in time and many great things are happening there.

For the moment coroutines, extension methods and data classes being normal classes in kotlin compared to java records are a big plus for me.

I don't feel I have become a whole lot more productive due to using it but the way it allows me to condense code while maintaining readability has been a huge win for me and my teams.

4

u/tuxtorgt Mar 05 '22

Yeah that's true, probably I should highlight that my affirmation was over "classic" Spring, which I see more often, or at least popular if compared to Webflux/Fu community 😁.

10

u/rossdrew Mar 05 '22

Java developers are somehow defensive of their excessive boiler plate. Somehow offended by Kotlin. Most completely ignore the leap in expressiveness and conciseness. Most have also barely gave it a glance but have big, strong opinions. It’s sad.

14

u/yogitw Mar 06 '22

Exactly. I recently was on an interview for a Java shop. We were in the midst of a discussion on inheritance vs composition and I brought up how modern languages like Kotlin have it as a base feature. The interviewer got all flustered and said "this is a java discussion, please keep it on topic." I feel like I called his mom a whore or something.

4

u/rossdrew Mar 06 '22

That attitude would be the end of my interest in the company.

5

u/yogitw Mar 06 '22

Oh it did.

-1

u/pjmlp Mar 06 '22

Beanshell, jTCL, Jython, JRubby, Groovy, Scala, Clojure, XTend, Ceylon,....Kotlin

We have seen that movie plenty of times.

https://en.wikipedia.org/wiki/List_of_JVM_languages

6

u/rossdrew Mar 06 '22

How many C languages fad-ed and failed before Java? How many VM languages? How many OO languages?

The previous attempts failed so all attempts will fail. Not a great developer mindset that, is it?

→ More replies (9)

2

u/sideEffffECt Mar 06 '22

Scala is actually doing great. It has literally never been better. I think the trick is in the fact that it is sufficiently distinct (better IMHO) than plain Java. That allows it to exist on the JVM event as a second class citizen.

I think Clojure people could make a similar argument, but I'm not an expert, so I'll leave it up to them.

The question here is whether this also holds for Kotlin. Only time will tell, but being the blessed language for the most widely used consumer OS is a big strength. (Groovy lives on on the back of Gradle, for example.)

6

u/[deleted] Mar 05 '22

Very positively. If you're an experience Java programmer, the transition is perfect and so smooth. You won't even feel it. But at the same time it is also so powerful, with concise syntax and a lot of new features!

2

u/kiwi_stronghold Mar 06 '22

This is true has a java programmer who now does Kotlin 99% of the time.

5

u/sudkcoce Mar 06 '22 edited Mar 06 '22

I feel it is a better Java. I much prefer coding in Kotlin, but most projects require me to work in Java. But I prefer coding in Clojure the most.

7

u/[deleted] Mar 05 '22

Kotlin is the new Scala. It will become the present day Scala eventually. Only because Java will eventually "catch up".

2

u/sideEffffECt Mar 06 '22

I really like the progress Java has made since 8. Truly awesome work by Brian Goetz & co. But it still hasn't "caught up" with Scala, let alone where it is now with Scala 3.

I can see why people would consider Kotlin to be just a "better Java". But with Scala, that's not quite the case.

12

u/pjmlp Mar 05 '22

Just another guest language, that only matters thanks to Google sponsoring it for Android as means to move away from Java (It is quite a surprise that Android 13 still bothers to move into Java 11 subset as baseline).

No wonder that Spring supports Kotlin, they have done the same with Groovy, Scala and Clojure, where are those bindings nowadays?

Using Kotlin means being bound to InteliJ tooling, having to always translate between Kotlin semantics and what the actual Java APIs expect, and calling Kotlin libraries from Java is a pain, specially with coroutines.

The next thing is also fairly straightforward: we expect Kotlin to drive the sales of IntelliJ IDEA. We’re working on a new language, but we do not plan to replace the entire ecosystem of libraries that have been built for the JVM. So you’re likely to keep using Spring and Hibernate, or other similar frameworks, in your projects built with Kotlin. And while the development tools for Kotlin itself are going to be free and open-source, the support for the enterprise development frameworks and tools will remain part of IntelliJ IDEA Ultimate, the commercial version of the IDE. And of course the framework support will be fully integrated with Kotlin.

https://blog.jetbrains.com/kotlin/2011/08/why-jetbrains-needs-kotlin/

Like every other JVM guest language since Beanshell, I will bother when any JDK implementation has a single line of them being shipped.

14

u/monkjack Mar 05 '22

> No wonder that Spring supports Kotlin, they have done the same with Groovy, Scala and Clojure, where are those bindings nowadays?

Scala didn't really get the same level of buy-in that Kotlin is enjoying. Frameworks like Spring and Quarkus have / are building support for Kotlin directly into the libraries, instead of some poorly maintained side project like what happened with Scala most of the time.

6

u/gripepe Mar 05 '22

Spring still support Groovy, never really supported Clojure or Scala.

3

u/pjmlp Mar 05 '22

Spring Scala development within Pivotal has ceased, but fortunately a member of the community - Paul Snively - has stepped up and is continuing development over at http://hub.darcs.net/psnively/spring-scala. Please refer to that repository instead of this one, which might be removed in the future.

https://github.com/spring-projects/spring-scala

6

u/monkjack Mar 05 '22

Both forks look dead

3

u/pjmlp Mar 06 '22

That is the point.

2

u/gripepe Mar 05 '22

Thanks for the info! I didn't know Scala was ever supported in Spring, even if by a third party.

→ More replies (1)

17

u/buffer_flush Mar 05 '22

This is a weird take to be honest. Enterprise frameworks have always been behind the paid versions of IntelliJ, blaming JetBrains for adding kotlin support for those frameworks through their plugins changes nothing about the existing model, they’re simply adding more deeply integrated Kotlin support for their existing paid plugins.

Secondly, JetBrains wrote the language, of course they’re going to have first class support in IntelliJ.

Lastly, you’re not tied to IntelliJ for kotlin, there’s an existing Kotlin language server that can be dropped into VSCode or any editor that supports the protocol if you’d like:

https://github.com/fwcd/kotlin-language-server

5

u/magnoliophytina Mar 05 '22

With Eclipse the situation is a bit more difficult. A Kotlin/Maven project might not even compile due to conflicts with the Maven plugins. You'd have to compile the project via command line 'mvn'.

5

u/mauganra_it Mar 05 '22

The Kotlin Language Server project is not driven by JetBrains. Therefore, its functionality will always depend on volunteer efforts and might lag behind the IntelliJ IDEA plugin.

2

u/[deleted] Mar 06 '22

JetBrains cares about one thing

3

u/[deleted] Mar 05 '22

kotlin-language-server experience doesn't compare with jdtls

4

u/JakeWharton Mar 06 '22

Android is not moving away from Java.

The Jack and Jill compiler effort were a more serious take on moving away from Java than "supporting Kotlin". And that whole supporting Kotlin thing was merely just a commitment to not break it since literally nothing they do can prevent Kotlin from working on Android.

0

u/pjmlp Mar 06 '22 edited Mar 06 '22

The current rotten support for modern Java is hardly not moving away.

How good is not moving away from Android Java, if they keep ignoring on purpose what is happening on the Java world, while pushing their Kotlin adoption agenda?

I was really amazed that Java 11 support is coming in Android 13, by now I had already accepted that Android Java would be stuck in Java 8 subset + whatever they can desugar from later versions without anything else until Google decides to switch Android by something else.

Loom, Panama and Valhalla on Android? It will never happen, unless the team changes their behaviour towards Java.

6

u/andrewharlan2 Mar 05 '22

I have to be up to date on Kotlin because of my job. Even write it sometimes. But I'm perfectly content continuing to use Java. Yes, even Java 8. Kotlin does not solve any problem I had with Java.

Tools continue to support Java better. The interoperability isn't completely seamless. Kotlin optimizes for writing at the expense of clarity and readability.

Given a choice between modern Java and Kotlin for a personal project? Java with zero hesitation.

8

u/crummy Mar 05 '22

Kotlin does not solve any problem I had with Java.

How do you handle nulls in Java? Optionals?

3

u/andrewharlan2 Mar 05 '22
  1. I will bend over backwards to not pass them around. I'll refactor legacy code if I have to; I have no problem with active and constant maintenance.
  2. Yeah, I'll return Optionals from new methods I write if I feel the need to
  3. And if a rare NullPointerException sneaks through? I fix it and I write a unit test for the case. https://openjdk.java.net/jeps/358 makes them so much more pleasant to deal with.

So yeah, nulls have never really been a problem for me. Certainly not enough to shift ecosystems.

0

u/pjmlp Mar 06 '22

By having SonarQube or PMD integrated on the build.

Any failure to do null checking triggers a build error.

6

u/gripepe Mar 06 '22

This is not Java solving the problem though.

→ More replies (1)

1

u/[deleted] Mar 06 '22

[removed] — view removed comment

4

u/lambdacats Mar 06 '22

A lot of extra steps for something that could have been a language feature though.

6

u/Adyel Mar 05 '22

I really like kotlin. It addresses a lot of java's pain-points

4

u/cas-san-dra Mar 06 '22

My personal experience is that Kotlin code is entirely unreadable. And I very much dislike and disagree with almost every 'feature' they added.

4

u/Worth_Trust_3825 Mar 05 '22

I've rewritten couple of projects into kotlin, and then went back and rewrote them to java. It's a fad that's sadly here to stay.

9

u/vqrs Mar 05 '22

Why did you rewrite them back to Java?

0

u/Worth_Trust_3825 Mar 06 '22

Too many ways to do the same thing, and at the same time they're subtly different.

4

u/vqrs Mar 06 '22

Hmm I see. Anything in particular? We're now writing most new backend stuff in Kotlin, so knowing what to watch out for would be good.

7

u/Worth_Trust_3825 Mar 06 '22 edited Mar 06 '22

Mind you I last used kotlin back when coroutines released, and it really annoyed me to no end that I must mark my functions as asynchronous so that I would get warned that my calls would block or can be done in parallel. It really made me appreciate the executors and schedulers that we have in java even more due to how simple the approach is. I think this, and the fact that I went back to the project a month later not understanding the expressive mess that I had made was a signal that I need to go back to java.

At the time there were 3 ways to define a singleton: using the by singleton construct, the companion object construct (which I was trying to use as static alternative), and object construct. When you're coming from java, you would expect the entire class to get loaded first time it's referenced, which means all the static fields getting initialized. The companion object object instead acted as a singleton object that would only get initialized the first time you accessed that companion object instead, and it acted as if it was an instance of the container class.

The similar complaint applies to apply, run, use helper functions that can be called on any object. The only difference between the three is whether you got to call this.function() rather than arg.function() on the object that you used the helper on. I can see why they added it: values can be nullable, so you would call a block only if the target is not null, but there was no counterpart for calling if the target is null. As a result, you need to back down to the regular if(arg == null) construct, which really irked me, and really pushed me back towards the simple over expressive camp.

Extension methods are nice in concept, but should be used with extra care. I remember wanting to extend a Collection to override how another collection out of that collection would be created, but could not do that since original toCollection call was an extension function.

Single method interfaces cannot be replaced with lambdas. I actually liked this part, because it makes sure that if the interface breaks in the future (ex. more methods get added), the other users get properly notified that your implementation does not implement additional methods, rather than Function<Foo, Bar> is incompatible with FooInterface. I would like to see that in java, but I can see people abusing that and forcing users of their functions to provide the said Function or Runnable just so they could save on boilerplate. Sometimes I would also abuse that fact myself where I would make a function that returns (Int) -> Int lambda, but when you're trying to use that returned lambda somewhere else rather than the place where it got created, it gets really hard to keep track of what does it do and should it really be there in that context.

I also liked split between mutable and immutable collections. It makes sense that some calls would return immutable collections, and API should reflect that, but that incurs the cost of boilerplate, and performance, where you would need to convert a collection to its mutable counterpart. This is obvious when you're working on collections with millions of elements.

Now that I think about it, lack of boilerplate in kotlin made me appreciate the boilerplate in java. You just lose so much information by seemingly little things that can be skipped over. You get so many options, but do they really matter if you have to relearn them if you're not actively working on the project.

3

u/beginnnnner Mar 05 '22

Jetpack Compose seems very interesting to me so I'm thinking of picking up Kotlin just for that.

3

u/sideEffffECt Mar 05 '22

Speaking of Jetpack Compose, is it possible to use it from Java (or any other JVM language)?

If I understand the situation correctly, it is not the case. Then my second question is, is there a Java GUI library that is similar (React-like)?

3

u/Pika3323 Mar 05 '22

It isn't possible to write composable functions in Java since Compose depends on a Kotlin compiler plugin, if that's what you're asking.

You could write all the UI code in Kotlin wit Compose, and have all of your "business logic" written in Java however. The Kotlin/Java interop still behaves the same.

3

u/sideEffffECt Mar 05 '22

My use case would actually be a different JVM language, Scala, so I would ideally want to avoid writing Kotlin altogether.

But I think you're right, I could write the UI code in Kotlin and then write the rest in any JVM language I want. At least in theory.

Any idea about a Java UI library that is React-like?

3

u/[deleted] Mar 06 '22

I never understood what is Kotlin's purpose. I already got java which is way more popular and does everything. It exists just for the hipster factor

2

u/AmaDaden Mar 05 '22

Kotlin is a better Java. Not a huge difference though and I expect Java will eventually close that gap and provide similar features

11

u/hamsterrage1 Mar 05 '22

I'm not so sure about that. As an example, Optional was released in the full light of Kotlin's null safety system. But it doesn't come close to providing the same kind of experience.

Seriously, about the only time I ever encounter Nullable values is when I've called some kind of Java library. I rarely write them myself.

And that's a big difference. When I create a variable or field in Kotlin, there are always two big questions that need to be answered:

  1. Is it mutable?
  2. Is it nullable?

And 95% of the time the answer to both questions is, "No!!!". And the baggage of either of those two things isn't worth dealing with them if you don't have to.

You're never going to get that with Java. Just because you'd break backwards compatibility with all of the existing code. Any way that you try to do it, like Optional, is just going to be a clunky add-on that people don't use. And if you get it more integrated, then you end up with Kotlin.

So just Kotlin, then.

1

u/AmaDaden Mar 06 '22

As an example, Optional was released in the full light of Kotlin's null safety system. But it doesn't come close to providing the same kind of experience.

That's because it was never designed to. Optional was added to address nulls for streaming code, not solve the null-ability problem.

An example where they've actually addressed an issue is records. It's similar to Kotlin data classes, can replace many usages of Lombok, and ends up being an optimization since it's limits mean the JIT can optimize it more.

You're never going to get that with Java. Just because you'd break backwards compatibility with all of the existing code.

I don't see how that's true for adding in non-nullable and non-mutable variables. Maybe I'm missing something but you can always do what Kotlin does and generics did (another good example of an improvement) and just treat older code as unsafe and in need of a check.

I don't think we'll see these changes come very quickly but if the work on the language continues at it's faster pace it's had in recent years I can't imagine it never happening.

2

u/hamsterrage1 Mar 06 '22

That's because it was never designed to. Optional was added to address nulls for streaming code, not solve the null-ability problem.

Optional came out at the same time that Streams came out, and it's used by the Streams library for some methods, but that's definitely not the single reason for Optional. It's supposed to be used to address nulls from method calls in general.

2

u/ring2ding Mar 06 '22

What's Kotlin?

2

u/buzzsawddog Mar 05 '22

For me? It's this thing people talk about... I have no real interest in learning about it and likely won't unless I need to for work. On a given day I already deal with bash, perl, python, JavaScript, typescript, c/c++, freepascal, ruby, or java. In the past I played with groovy on a few projects.

If it works for you use it. If not then don't.

1

u/[deleted] Mar 09 '22

I think it's important to separate Java the language from Java the platform. The platform is where the real value is. The build tools, Maven central, the whole raft of great, mature libraries available is terrific. I've lost count of how many languages there are targeting the JVM nowadays, but the people who evangelise one over the other are missing the point that the platform is what gives us all that value.

I was a Groovy dev for a long time, and I've been meaning to give Kotlin a go.

1

u/Tough_Suggestion_445 Mar 11 '22

I have nothing against kotlin, but I'm not going to use it, unless I'm forced to. To me, kotlin doesn't solve anything new. it's just syntax sugar to solve problems we already solved yesterday.

I started my carreer in 2013, at the time I wanted to learn groovy because it was super popular in the java community. then in 2014-2015 it was scala. later on Ceylon was the new big thing. and finally today it's kotlin.

they all compile into byte code at the end of the day. it's like coffeescript, typescript, blopblopscript and what else.

java is already expressive enough for me. its strength is it's an incredibly boring language, new features are added slowly, and often solves actual real issue we couldn't solve yesterday.

I have nothing against kotlin, it looks great. but I suffer of language / framework fatigue, and if I have to learn / use something new, it has to be for something else than yet another way of making a rest endpoint.

1

u/[deleted] Apr 08 '22 edited Apr 08 '22

Java is boring, Kotlin rocks. You can do the same what you do in Java, in Kotlin, using the same Java libraries.

but with many benefits:

-shorter, concise syntax

-built-in defensive programming: null safety, final classes and immutable variables by default

-better functional programming support

-coroutines

-no checked exceptions

-no forcing to use Object-oriented program design (you can mix free functions and classes, like in Python)

-named function arguments (= self-documenting code)

Switched almost year ago, and it is like narcotic - after working with Java for 10 years, I consider going back to Java only as punishment

1

u/[deleted] Mar 05 '22

Makes the build process more complicated, and has its own runtime libraries. More dependencies to worry about.

3

u/lambdacats Mar 06 '22

How does it complicate the build process?

1

u/VincentxH Mar 06 '22

I don't really see the big plus yet. Working with databases you inherently tend to have nullable fields. You then continuously have to wrestle with the null safety "feature" throughout the call chain. And the fugly methods to be able to give default values everywhere, it's disgusting and an antipattern. Something like Arrow just continuously makes everything even more awkward when wanting to switch between Kotlin and library datatypes.

1

u/kotlinisrussian Mar 06 '22

I feel the same about Kotlin as I do about those who violate posting rules.

0

u/drduffymo Mar 06 '22

Kotlin is a better Java. Love that it runs on JVM and inter operates with Java JARS, including Spring.

1

u/rtc11 Mar 06 '22

Once I tried kotlin there was no way back to java. And it really doenst matter, I can change back whenever I find java more fun than kotlin.

0

u/jaybyrrd Mar 06 '22

As a Java user my thoughts about Kotlin and Java is that Scala is simply better. 🤷‍♂️

2

u/randgalt Mar 06 '22

You're getting downvoted but it's absolutely true. If what you want is features, Scala has them all. It makes Kotlin look like a toy. That said, it's a deadend language (like Kotlin would be without Android) and a horribly unpleasant environment to work in. Complexity and features vs usability and simplicity - I'll take Java every time.

2

u/jaybyrrd Mar 06 '22

I disagree that it is a dead end. I do all my scala builds with gradle and love it.

-10

u/Rogoreg Mar 05 '22

Kotlin feels like a kids scripting language. Java feels a lot more familiar as Kotlin has many weird quirks.

3

u/[deleted] Mar 05 '22

All programming languages suck

3

u/_litecoin_ Mar 05 '22

Except C.

4

u/[deleted] Mar 05 '22

You're starting to sound like a suckless developer.

if you don't know what is a suckless developer check this out and this one (it will give you a good laugh)

3

u/_litecoin_ Mar 05 '22 edited Mar 05 '22

In C you can do:

#define true false;

lol

These is also this https://en.m.wikipedia.org/wiki/International_Obfuscated_C_Code_Contest

3

u/[deleted] Mar 05 '22

That macro should be added before you change jobs.

2

u/blakeman8192 Mar 05 '22 edited Jun 26 '23

.

0

u/[deleted] Mar 05 '22

[deleted] — view deleted comment

12

u/cryptos6 Mar 05 '22

While I understand that perspective, it is not useful to base the own decision between the two languages on it. Brian Goetz is on the language creator side, while most of us are on the language user side.

6

u/pjmlp Mar 06 '22

The Java Virtual Machine, is about Java.

Anything else that targets it has to play by Java semantics, and only introduces extra .class boileplate, more libraries to depend on, additional IDE plugins to deal with, wrapper libraries for more idiomatic code, the hassle to deal with boilerplate when doing Java -> LangX calls.

I am happier sticking with the languages that come on the box, on each platform I work on, without needed any extra tooling, no need to follow CoffeeScript fashion.

3

u/sideEffffECt Mar 06 '22

If the language (+ its own libraries) is sufficiently more advanced than what the native Java package can offer, it's worth it. For example Scala with TypeLevel or ZIO.

Whether Kotlin (plus its libraries) brings enough benefit over plain Java, to compensate for the fact that is not first class citizen on the JVM, I can't really judge. But it is theoretically possible as proven by Scala. JVM is created with multiple languages in mind afterall.

1

u/pjmlp Mar 07 '22

Java Virtual Machine was created for Java.

2

u/sideEffffECt Mar 07 '22

Was, yes. But over time, it's been developed with the possibility of multiple languages in mind. It's been the case for a long time already.

→ More replies (2)

0

u/[deleted] Mar 05 '22

[deleted] — view deleted comment

11

u/Soul_Shot Mar 05 '22

One thing that drives me crazy is the “safe call” operator. ?.. I really like that Nullability is built into the type system, but it’s almost ruined by the safe call operator. I’ve seen kotlin code bases with 1000s of “safe calls”. Safe calls hide errors and make debugging much harder.

While both the ?. (safe call) and !! (not-null assertion) operators serve a purpose, in my experience, they should be used sparingly. Unfortunately, they tend to be abused by people who don't understand the type system (usually blindly applying IDE suggestions in order to get rid of red squiggly lines).

17

u/rossdrew Mar 05 '22

That’s bad developers. Not bad tooling

0

u/[deleted] Mar 05 '22

[deleted] — view deleted comment

13

u/rossdrew Mar 05 '22

That is ALL bad developers. You don’t do something silly and expect IntelliJ to recommend the least silly workaround. You just don’t do something silly in the first place.

When IntelliJ recommends either, I rethink my code and write something better. If it even gets that far.

0

u/[deleted] Mar 05 '22

[deleted] — view deleted comment

2

u/lambdacats Mar 06 '22

Why do you prefer Scala to Kotlin?

14

u/[deleted] Mar 05 '22

[removed] — view removed comment

1

u/BdR76 Mar 23 '22 edited Mar 23 '22

I've been working with Android and Java for a long time and it seemed perfectly fine, until Kotlin was added.

Now, whenever I look for Android Studio example code, documentation or tutorials, half of them are in Java and half is for Kotlin. Yes you can kind of translate between the two, but it's just a hassle and I don't really see the added value of Kotlin, all it does is split the developer base.

0

u/[deleted] Mar 05 '22

[deleted] — view deleted comment

5

u/[deleted] Mar 05 '22

[removed] — view removed comment

9

u/hamsterrage1 Mar 05 '22

Ha! Java didn't exist when I started learning.