This document provides a quick comparison of Kotlin to Java.
Fixes
Safety problems in Java that are fixed in Kotlin:
- Null references are controlled by the type system, i.e. Kotlin has no NPE's
- Full type information is retained at runtime, i.e. better reflection/safer instanceof-checks
- No raw types
- Arrays in Kotlin are invariant
Usability problems in Java that are fixed in Kotlin:
- Kotlin has higher-order functions, aka closures
- And with inlining they are cheap
- Use-site variance without wildcards
- Declaration-site variance
- Kotlin has no checked exceptions
What Java has and Kotlin has not
- Checked exceptions
- Primitive types that are not objects
- Static members
- Non-private fields
- Type erasure
- Wildcard-types
What Kotlin has and Java has not
- Function literals + Inline functions = performant custom control structures
- Null-safety
- Smart casts
- String templates
- Properties
- Primary constructors
- Mixins and First-class delegation
- Extension functions
- Type inference for variable and property types
- Singletons
- Declaration-site variance & Type projections
- Modules
- Range expressions
- Pattern matching
- Generic types retained at runtime
- Operator overloading
- Class objects
What's next
Labels:
None

3 Comments
comments.show.hideNov 11, 2012
Michael Hübner
A new language brings advantages for the developer who understands (and loves) the concepts.
But it would be good to have a transformation to Java (beside the direct transformation to JVM byte code).
Because usually there is a lot of resistance for acceptance of a new language (e.g. Scala).
Co-workers know Java and don't want to spend time to learn a new language and new concepts.
Project managament is affraid that the language might disappear in the near future,
i.e. that the just developped program will be legacy code without support on new platforms,
or that the maintenance is a problem if the original developer is not available and no one else in the enterprise knows the language.
Mar 29, 2013
Hans Marggraff
A feature of Java 8 Lambdas are method references. I observe in my Kotlin-code, that I would like to use them frequently.
Is there an equivalent in Kotlin. Or is it planned to have one in the future?
Mar 29, 2013
Andrey Breslav
We are working on this feature.