▲ | twen_ty 2 days ago | |||||||
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? | ||||||||
▲ | flanked-evergl 2 days ago | parent | next [-] | |||||||
> 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. But to answer your question that is loaded to the brim with false assumptions/claims directly: https://kotlinlang.org/docs/comparison-to-java.html | ||||||||
| ||||||||
▲ | thuridas 2 days ago | parent | prev | next [-] | |||||||
- It has the best null handling mechanism - 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 | ||||||||
| ||||||||
▲ | adra 2 days ago | parent | prev | next [-] | |||||||
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 | ||||||||
▲ | pjmlp 2 days ago | parent | prev | next [-] | |||||||
Having to target Android, Google's .NET, mostly. | ||||||||
| ||||||||
▲ | rbehrends a day ago | parent | prev | next [-] | |||||||
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. | ||||||||
| ||||||||
▲ | Larrikin 2 days ago | parent | prev | next [-] | |||||||
>after Java 21/23, what's the argument for using Kotlin Having to use Java again when Kotlin exist | ||||||||
▲ | gavinray 2 days ago | parent | prev [-] | |||||||
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. For example, something like:
In Java, you have "Function3<A, B, C>" etc |