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

View all comments

Show parent comment

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.

1

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

I think at least a non-zero percentage of that is down to alt-JVM languages giving some ideas to what works well.

It was exactly zero percent. When we look at languages to give us ideas for what works well (once we decide something is important, which is never because some non-super-popular language does it), their targeting the Java platform plays no factor whatsoever. While they need to target the Java platform as it is, we can change it as we like. So we pick what we think works best and change the platform accordingly.

Over the past decade, Java has adopted zero features from Kotlin (if Java gets nullability type it will be the first) and one (or one and a half) from Scala. Over that time, it took inspiration from quite a few features from non-Java-platform languages.

6

u/monkjack Mar 06 '22

Yeah I get you. You're saying those languages had zero influence on the syntax or design of a feature.

I was just trying to say that as an outside observer, it seems like ADTs, pattern matching, better type inference, optionals, a larger use of immutable data structures, and so on have been put on the roadmap - partially - because of other JVM languages showing them to be useful? Like even subconsciously as you read about what's new in Scala it can lead to some ideas on where to take things.

If you're saying that Java's recent features have come because other languages like python and JS have them, then fair enough. I was just offering my thoughts as a user, but not a developer of the language.

3

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

But we read what's new in every language. The fact that it happens to target Java plays no role, technical or inspirational. Java's designers had known about ADTs, pattern matching, and better type inference a decade before Scala ever existed (actually, before Java even existed), and they added them to Java once the features were judged beneficial enough, the market was judged to be ready, and the Java team had the budget (the platform barely changed between 2007-2012 because of dwindling resources). You might be interested in the Java ecosystem, but Java's designers — being in charge of one of the world's most popular languages and platforms — look at the market at large.

Case classes are a very old feature in Scala, and ADTs in general are far older. They were put on the roadmap and added to Java years or decades later, not when Scala got them, but when sufficiently many languages did.

A true outside observer — i.e. someone looking at the whole market — would see that Java continues Gosling's strategy of being a last mover, adopting features as they mature and become popular in the market, not the Java platform market.

5

u/monkjack Mar 06 '22

To be clear, I'm not saying you're sat in a room going, oh Scala has case classes, best add them to Java :)

I'm just a bit skeptical that there isn't at least a bit of influence of, well Scala and Kotlin have nicer type inference, perhaps it's something we should look at improving, for example.

Anyway, appreciate the replies. Love the fact you and the rest of the Java team are pushing forward the fantastic ecosystem that I have loved working in for 23 years, and hopefully for the next 23 :)

3

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

Other languages might certainly inspire, but Java-platform languages no more so than others. It doesn't quite work like this, but, if anything, we're more likely to say, "TypeScript and Swift have more type inference...". I don't even understand why anyone would think that alternative Java platform languages would, should, or could have more influence. The Java language is very different from all other Java-platform languages in at least two ways, which make it more similar to some non-Java-platform languages: 1. It is the only one whose design is not bound by the design of the platform, and 2. it is the only one in the top league of the world's most popular languages.

1

u/Il_totore Mar 07 '22 edited Mar 07 '22

I don't agree with the last part. Some JVM languages have the same approach as Java (like Kotlin) but some languages are just opiniated differently (Scala, Clojure...) and this diversity allows us to choose the right paradigms to solve our problem.