HN user

driver733

163 karma

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

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

Posts3
Comments11
View on HN
Kotlin vs. Java 7 years ago

That's not always the case, since Kotlin can generate Java 6 compatible bytecode.

Kotlin vs. Java 7 years ago

It can be done this way:

  result = Optional.ofNullable(nullableVariable)
                   .map(NullableType::someMethodCall)
                   .orElseGet(() -> fallbackIfNullMethodCall());
Kotlin vs. Java 7 years ago

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.

Kotlin vs. Java 7 years ago

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.

Kotlin vs. Java 7 years ago

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.

Kotlin vs. Java 7 years ago

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.