News for hackers. Stuff that matters.
Re:Kotlin becomes second most popular language on the JVM by jillesvangurp on Thursday February 06, 2020 @10:57AM (#22256982)
Everything Java does (including considering recent updates), Kotlin does better. So no. I made the switch to Kotlin two years ago and I'm not looking back. It doesn't matter what frameworks you use, Kotlin is a drop in replacement for Java. Though obviously, if you are doing greenfield use something that makes the most of the language.

There's this misconception that Kotlin is an Android only thing or a JVM only thing. The reality in both Android and server side frameworks is that the big frameworks are all moving towards being Kotlin friendly/ready. Additionally, Kotlin is rapidly moving towards being a proper full stack language with a native compiler (currently in beta), a javascript transpiler, and lots of other tooling maturing. People are already doing cross IOS/Android libraries in Kotlin.

A big advantage of Kotlin over e.g. Scala and other JVM languages that are not Java is that it is designed from the ground up make the transition as seamless as possible. Scala is so far removed from Java that it's generally a completely separate ecosystem with its own libraries, tools, frameworks, idioms, etc. Yes you can use Java stuff but it's generally frowned upon by Scala people.

This is not the case with Kotlin at all. The Android ecosystem started transitioning to Kotlin long before Google recommended that and before Kotlin 1.0 because the pain of having to deal with Java 6/7 just made that development so much better. A few years ago they started endorsing and recommending it and at this point they are clearly deprecating a lot of stuff that they did for Java that can be done better with Kotlin e.g. embracing co-routines over rxjava, adding extension functions and kotlin dsls and designing new features that really only make sense if you use Kotlin. On Android, if you are doing Java, you are working on a legacy code base.

On the server side the same is happening with e.g, Spring, which is basically the dominant server side framework for the JVM. I used Kotlin with Spring Boot 1.x/Spring 4.x, and it was a nice upgrade despite the lack of Kotlin support for it.

With Spring 5 and Spring Boot 2.x they started adding a lot of Kotlin extension functions, co-routine support (which generally makes using their reactive stuff less painful), and there's an experimental project for Kotlin DSL (https://github.com/spring-projects-experimental/spring-fu) to replace the mess of annotations that is currently needed and which reduces the need for reflection, proxies, and other tricks that currently make using Spring with Graal vm hard. Basically, what that means is that if you use Spring in a new project and you are not using Kotlin, you are probably making a mistake because you are missing out on a lot of good stuff. They'll likely not deprecate Java entirely for a long time just because there are a lot of very conservative projects in e.g. banks using Java but if you read between the lines they are basically saying Kotlin is it going forward.

IMHO, the Java language is definitely improving but just not at a pace where it actually keeps up and a lot of the stuff they add is a big compromise compared to what you get in Kotlin. and of course Kotlin is improving as well and a lot of the Java changes (and related JVM changes) also benefit Kotlin.

Re:Kotlin becomes second most popular language on the JVM by lmm on Thursday February 06, 2020 @10:08PM (#22262897)
> A big advantage of Kotlin over e.g. Scala and other JVM languages that are not Java is that it is designed from the ground up make the transition as seamless as possible. Scala is so far removed from Java that it's generally a completely separate ecosystem with its own libraries, tools, frameworks, idioms, etc. Yes you can use Java stuff but it's generally frowned upon by Scala people.

> This is not the case with Kotlin at all. The Android ecosystem started transitioning to Kotlin long before Google recommended that and before Kotlin 1.0 because the pain of having to deal with Java 6/7 just made that development so much better. A few years ago they started endorsing and recommending it and at this point they are clearly deprecating a lot of stuff that they did for Java that can be done better with Kotlin e.g. embracing co-routines over rxjava, adding extension functions and kotlin dsls and designing new features that really only make sense if you use Kotlin. On Android, if you are doing Java, you are working on a legacy code base.

There's a contradiction between your paragraphs; my experience is that as Kotlin projects mature, they also reach a point where developers frown on Java idioms. I mean fundamentally either the language is different from Java or it isn't; if it is, the transition isn't going to be seamless, and if it isn't, then why use it? The Kotlin community may have been better at being supportive, but the practical experience of making the transition is exactly the same (e.g. I used Spring for my early Scala projects, and found that to be a very nice way of working).

Re:Kotlin becomes second most popular language on the JVM by thu2111 on Friday February 07, 2020 @03:25AM (#22264138)
Which Java idioms do Kotlin programmers frown on? (I am one)

The only ones I can think of are where the language provides a feature that automates some Java boilerplate, so it wouldn't make sense to write things out by hand anymore. Otherwise they're semantically identical languages so the gap isn't big.

Re:Kotlin becomes second most popular language on the JVM by lmm on Friday February 07, 2020 @07:11PM (#22272588)
Things like builders no longer make sense if you have named arguments. Transforming or filtering a collection is more idiomatic than mutating it in-place. Factories don't make sense when first-class functions do the job better. Basically everything that's frowned on in Scala is also frowned on in Kotlin, in my experience.
Re:Kotlin becomes second most popular language on the JVM by thu2111 on Saturday February 08, 2020 @09:31AM (#22275870)
Good points. It'd be great if the kotlin compiler could produce builders or "withers" automatically.
Re:Kotlin becomes second most popular language on the JVM by lmm on Saturday February 08, 2020 @07:35PM (#22279630)
Would you really want them? If you write code in that style then you're giving up a lot of the advantages of Kotlin.

IMO there's a contradiction at the heart of Kotlin's positioning. As the quote goes, a language that doesn't affect the way you think about programming, is not worth knowing. If programming Kotlin is just like programming Java, why not just keep programming Java? If you want to switch to Kotlin because it's going to unlock a better way of programming, then that's going to have to mean changing how you program. It may work as a trick to get users on board at the start, but ultimately the language will have to find its own idioms and patterns, or else go the way of CoffeeScript.

Re:Kotlin becomes second most popular language on the JVM by thu2111 on Monday February 10, 2020 @08:59AM (#22289115)
I'm talking about what it compiles down to. Kotlin routinely generates bytecode that uses Java idioms either for its own ABI or in addition to it. So yeah, if some builder classes were produced behind the scenes for an immutable data class, why not, that'd be cool. You could always disable that feature with a flag if for some reason the bytecode size was an issue.
Re:Kotlin becomes second most popular language on the JVM by pjmlp on Thursday February 06, 2020 @01:17PM (#22258571)
Still waiting for the KVM, given that Kotlin is so much better then it can have its own platform, written from scratch in Kotlin/Native, running circles around GraalVM, without dependencies on lower quality Java libraries.