Kotlin is a statically typed, multi-paradigm language developed by JetBrains and released in 2016. It compiles to JVM bytecode, JavaScript or native code, and it interoperates fully with existing Java libraries.
Why it matters
Google made Kotlin its preferred language for Android development in 2019, and it is also used for server-side work with frameworks such as Spring and Ktor. Compared with Java it is more concise: data classes, type inference, default arguments and extension functions remove boilerplate. Its type system separates nullable from non-nullable types, which eliminates many NullPointerException errors at compile time.
Example
data class Site(val name: String, val up: Boolean)
fun main() {
val sites = listOf(Site("a", true), Site("b", false))
val down = sites.filter { !it.up }.map { it.name }
println(down) // [b]
}
The data class generates equals, toString and copy automatically, and it names the lambda parameter.
Common mistakes
- Using
!!to force non-null values, which throws if the value is null. - Calling Java APIs without realizing their return types may be null ("platform types").
- Blocking the main thread in Android instead of using coroutines.
Related
Get notified when this term updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.