Files
kotlin-fork/docs/confluence.jetbrains.com/Kotlin/40702623_Comparison+to+Java.confluence
T
2012-05-30 14:41:40 +04:00

49 lines
2.0 KiB
Plaintext

This document provides a quick comparison of [Kotlin] to *Java*.
h3. 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|Null-safety]
* Full type information is [retained at runtime|Generics#Reified generics], i.e. better reflection/safer instanceof-checks
* [No raw types|Java interoperability#Java generics in Up]
* Arrays in [Kotlin] are [invariant|Basic types#Arrays]
Usability problems in *Java* that are fixed in [Kotlin]:
* [Kotlin] has [higher-order functions|Functions#Higher-order functions], aka closures
** And with [inlining|Functions#Inline functions] they are cheap
* [Use-site variance without wildcards|Generics#Type projections]
* [Declaration-site variance|Generics#Declaration-site variance]
* [Kotlin] has [no checked exceptions|Exceptions]
h3. What Java has and [Kotlin] has not
* [Checked exceptions|Exceptions]
* [Primitive types|Basic types] that are not objects
* [Static members|Classes and Inheritance#Class objects]
* [Non-private fields|Properties And Fields]
* [Type erasure|Java interoperability#Java generics in Up]
* [Wildcard-types|Generics#Variance]
h3. What [Kotlin] has and Java has not
* [Function literals] + [Inline functions|Functions#Inline functions] = performant custom control structures
* [Null-safety]
* [Smart casts|Type casts]
* [String templates|Strings#Templates]
* [Properties|Properties And Fields]
* [Primary constructors|Classes and Inheritance#Primary constructors]
* [Mixins and First-class delegation|Classes and Inheritance#Inheritance]
* [Extension functions]
* [Type inference for variable and property types|Basic syntax walk-through#Define a local variable]
* [Singletons|Object expressions and Declarations]
* [Declaration-site variance & Type projections|Generics#Variance]
* [Modules|Modules and Compilation]
* [Range expressions|Ranges]
* [Pattern matching]
* [Generic types retained at runtime|Generics#Reified generics]
* [Operator overloading]
* [Class objects|Generics#Class objects]
h3. What's next
* [Comparison to Scala]