Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Kotlin vs Java 1

Status
Not open for further replies.

Rick C. Hodgin

Programmer
Oct 15, 2021
172
US
Ellie Windler said:
Original post: thread1797-1793888

Making a decision for choosing the best programming language can be a tricky job. which one is better: Kotlin or java

I do not see the advantage of Kotlin over Java save in the area of licensing. I actually think Kotlin is a less structured, less well thought out language.

[UPDATE: I should clarify that statement. Kotlin seems to be concerned about user code authoring. Many of the things Kotlin does can be done using a pre-processor if required. Common / oft-repetitive tasks can be automated with the use of a few tools. While Kotlin brings that into the compiler, it's a philosophy I do disagree with strongly. I would rather see the ability to specify custom addons which can take source files and preprocess them, allowing the generated output from that preprocessing to be fed into the compiler.

Kotlin features I do like and wish Java had:
1. Ability to pass-in or return functions. I think this feature has been sorely missing from Java.
2. Null safety. C# has this as well. It's something Java is missing.]


I'll never switch to Kotlin unless I have to.

--
Rick C. Hodgin
 
I feel Kotlin is much more versatile when it comes to Android Studio.
Plus, Kotlin also makes the code much shorter and easy to manage.
 
I think there is no such thing as "Kotlin or Java".
Since Kotlin runs on the Java platform, you definitely need to know Java if you want to use it. In my opinion, any attempt to program in Kotlin without prior knowledge of Java will fail.

Why should I use Kotlin? To make the code shorter?
No, that's not a reason for me, because today's Java IDEs such as Eclipse and IntellijIDEA relieve the Java programmer of a lot of manual writing.

For me personally, Kotlin's syntax is not compatible with Java (I won't say it's ugly)
If I want to use a lot of syntactic sugar and make my code shorter, I prefer Groovy, which I think is much nicer syntactically and much closer to Java.
 
Kotlin was created in 2009-2010 when the following were true:

The Java language -- and, to a lesser degree, the platform -- was stagnant in Sun's dying days.

Android, while never actually compatible with Java, was very similar to it.

Neither is true now.

Android and Java are no longer similar, and are getting more dissimilar by the day. Kotlin is left trying to target two dissimilar platforms while still trying to be close to the "metal" for both (i.e. without introducing higher-level constructs that might have a runtime overhead like, say, Clojure) over the direction of neither of which it has much influence, and with particularly little influence over Java.

Java, both the language and the platform, has also evolved considerably, leaving Kotlin -- whose main market is now Android -- with features that are increasingly at odds with the platform's direction, like coroutines (the Java platform is taking a very different approach with Loom) and data classes (Java has also taken a very different approach, with records). I expect this gap between Kotlin, which is primarily an Android language, and the Java platform to only grow.

There isn't much Kotlin can do about it without making some tough decisions. It can effectively split into two languages, one targeting the Java platform and one targeting Android, or it can continue focusing on Android, where most of its market is, allowing its mismatch with Java to grow. If it does the latter, which is the path it's currently on, it will be mostly convenient as an "Android-first" language that can also be used to run code on Java but doesn't give the best experience on that platform; if it changes tracks and does the former, expect some big changes to Kotlin, but even then, the "Kotlin-for-Java" flavour will be a second-class citizen.

Finally, I find Java today -- now that nice things have been added to it and less nice things have been added to Kotlin -- to be the better-designed, more pleasant language, especially when working in large teams (although I do like Kotlin's nullability types and hope that the Java language will get them, or something similar, someday), but that's always a personal aesthetic choice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top