By Andy Balaam
Concrete examples, based on real-world code, of how converting Java code to Kotlin improves it.
We will cover:
-
Reducing the amount of code for common patterns like value objects and default parameters
-
Preventing errors using immutability, null safety and explicit inheritance
-
Expressing ideas more directly using pattern matching, sealed classes and conditional expressions
-
Less verbose functional-style code like streams and lambdas
-
Clearer object structure with primary and secondary constructors
One of the joys of Kotlin is how easy it is to make a gradual transition from Java. All of the examples will demonstrate code that can be dropped in to an existing Java code base with little or no disruption.
If we have time, we’ll discuss things we wish were in Kotlin, and whether any of them are plausible on the JVM platform.