HNHacker News
TopNewBestAskShowJobs

driver733

163 karma · joined December 23, 2018

Kotlin/Java developer, blogger, OOP and EO (elegantobjects.org) evangelist.

Blog: https://www.driver733.com GitHub: https://github.com/driver733

submissionscomments
driver733··on Kotlin vs. Java
That's not always the case, since Kotlin can generate Java 6 compatible bytecode.
driver733··on Kotlin vs. Java
I completely agree. I'll make that change soon.

Thanks for the feedback.

driver733··on Kotlin vs. Java
It can be done this way:

  result = Optional.ofNullable(nullableVariable)
                   .map(NullableType::someMethodCall)
                   .orElseGet(() -> fallbackIfNullMethodCall());
driver733··on Kotlin vs. Java
My goal is to compare Kotlin with the current version of Java along with any Java libs that are commonly used (such as Lombok). I have mentioned the fact that some teams are still on older versions of Java just to highlight that not every developer can access the features of the latest Java release.
driver733··on Kotlin vs. Java
You might find this article interesting. https://www.pragmaticobjects.com/chapters/001_checked_except...
driver733··on Kotlin vs. Java
I leave it to the reader to decide whether the advantages are clear or not.

For instance, in Kotlin you can perform operations on collection without converting them to a stream first, and collecting them with a certain collector afterwards. So in order to perform a single filtering operation on a collection, you need to do three steps in Java and just one in Kotlin.

Another advantage is coroutines, which not only allow you to write asynchronous code in a common, synchronous manner, but also get rid of shared mutable state, since coroutines can send/receive shared state through channels.

driver733··on Kotlin vs. Java
Sure, but you have take into account that Android devs are limited to Java 6, most enterprise devs (based on my experience) are still on Java 8 and some are still on Java 5 or below.
driver733··on Kotlin vs. Java
It is, however, even in the scope of the "Hello world" app, Kotlin performs much better than Java in terms of bringing out business logic to the front.
driver733··on Kotlin vs. Java
You are right, but you still have to catch the checked IOException.
driver733··on Kotlin vs. Java
They will. I am in the process of updating Java code snippets to Java 11.
driver733··on Kotlin vs. Java
To be more precise, I would say that expressive code == good code