Apart from legacy projects written in Kotlin, after Java 21/23, what's the argument for using Kotlin anymore, especially that it's a proprietary language?
In what sense is Kotlin a proprietary language? It's Apache 2.0 licensed AFAIK. And there are many projects that use Kotlin which are not legacy projects.
I love java and kotlin. The gap has certainly swayed way more in Java's favor over the last 5 years, but there are still a ton of great features that kotlin does first and if that gives java a target to run toward in a lagging way more legacy compatible rock solid way, isn't this just a win for both camps? Just consider kotlin (JVM) to be java-beta with slightly different flourishes, and you wouldn't be too far from the truth. Kotlin is also very big in pushing their other initiatives that aren't entirely directed at JVM at least for now, like cross compilation native targets, compile time serialization primitives, totally structured concurrency, etc
Aside from the often cited nullability issue, here is an (incomplete) list of important things that Kotlin still does better than Java:
- First class, fully functional closures.
- Non-abstract classes and methods are final by default.
- Named parameters.
- Easy to write iterators via sequence { ... }
- First class support for unsigned types.
Honestly, lack of the ability to write free-floating functions in Java.
Recent Java features like records, pattern matching, sum types via sealed interfaces have certainly made it a much more ergonomic and modern language.
But having to wrap everything in "class" feels ludicrous to me.
The other ones are lack of explicit null types (meant to be addressed by JEP "Null-Restricted and Nullable Types") and inability to write anonymous types for functions.
flanked-evergl|9 months ago
In what sense is Kotlin a proprietary language? It's Apache 2.0 licensed AFAIK. And there are many projects that use Kotlin which are not legacy projects.
But to answer your question that is loaded to the brim with false assumptions/claims directly: https://kotlinlang.org/docs/comparison-to-java.html
Aaron2222|9 months ago
Yes. Kotlin is free, has been free and will remain free. It is developed under the Apache 2.0 license, and the source code is available on GitHub.
thuridas|9 months ago
- Java handling of mutability of variables and collections
- Java is still more verbose and with less powerful utilities
- Much better for functional programming
-Some things were done right with all the learnt lessons. E.j. equals Vs ==
I respect preferring free languages. But I love Kotlin
Aaron2222|9 months ago
From https://kotlinlang.org/docs/faq.html#is-kotlin-free:
Yes. Kotlin is free, has been free and will remain free. It is developed under the Apache 2.0 license, and the source code is available on GitHub.
adra|9 months ago
pjmlp|9 months ago
cosmic_cheese|9 months ago
rbehrends|9 months ago
- First class, fully functional closures. - Non-abstract classes and methods are final by default. - Named parameters. - Easy to write iterators via sequence { ... } - First class support for unsigned types.
ab5tract|9 months ago
mr7uca|9 months ago
Larrikin|9 months ago
Having to use Java again when Kotlin exist
gavinray|9 months ago
Recent Java features like records, pattern matching, sum types via sealed interfaces have certainly made it a much more ergonomic and modern language.
But having to wrap everything in "class" feels ludicrous to me.
The other ones are lack of explicit null types (meant to be addressed by JEP "Null-Restricted and Nullable Types") and inability to write anonymous types for functions.
For example, something like:
In Java, you have "Function3<A, B, C>" etc