Skip to main content

Kotlin

Updated 2 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/kotlin

In short

Kotlin is a concise, statically typed language that runs on the JVM, works seamlessly with Java, and is widely used for Android and server-side development.

What is Kotlin?

Kotlin is a general-purpose programming language developed by JetBrains and first released as version 1.0 in 2016. It was designed to address common pain points of Java while working seamlessly with it: Kotlin code can call Java libraries, and Java code can call Kotlin, often in the same project. In 2019, Google announced Kotlin as its preferred language for Android app development.

Kotlin is statically typed, with strong type inference, so val name = "Ada" is known to be a String without saying so. Types are non-nullable by default: a variable that may hold null must be declared with a question mark, such as String?, and the compiler forces you to handle the missing case. On the JVM, memory is managed by the JVM's garbage collector, and Kotlin can also compile to JavaScript, WebAssembly, and native code.

Kotlin is used for Android apps, server-side applications, and cross-platform projects that share business logic between Android, iOS, desktop, and web through Kotlin Multiplatform. Coroutines, a built-in way to write asynchronous code that reads like ordinary sequential code, make networking and background work simpler. Kotlin compared with Java is a bit like a newer car model that uses the same roads and fuel: it runs on the same JVM and libraries, but with extra safety features built in.

Kotlin is often seen as a replacement for Java, but it is better understood as a companion. It compiles to the same JVM bytecode, so teams commonly mix both languages in one codebase and migrate gradually. Typical differences in everyday code include null safety, data classes that remove boilerplate, and extension functions that add methods to existing types.

Key takeaways

  • Kotlin compiles to JVM bytecode and interoperates fully with Java.
  • Types are non-nullable by default, which helps prevent null pointer errors.
  • It is statically typed with strong type inference and concise syntax.
  • Coroutines provide lightweight asynchronous and concurrent programming.
  • Kotlin can also target JavaScript, WebAssembly, and native code for multiplatform projects.

Example

Data classes and null safetykotlin
// A data class gets equals, hashCode, toString and copy for free
data class User(val name: String, val email: String?)

fun main() {
    val users = listOf(User("Ada", "ada@example.com"), User("Grace", null))

    for (user in users) {
        // ?. is a safe call and ?: supplies a default when the value is null
        val domain = user.email?.substringAfter("@") ?: "no email"
        println("${user.name}: $domain")
    }
}

Readers ask

What is the difference between Kotlin and Java?

Both compile to JVM bytecode and can be used together in the same project. Kotlin adds null safety in the type system, data classes, extension functions, and coroutines with more concise syntax, while Java has a longer history and a larger body of existing code.

Do I need to know Java to learn Kotlin?

No. Kotlin can be learned as a first language, although knowing Java helps when reading older Android code or using Java libraries.

Is Kotlin only for Android?

No. Kotlin is also used for server-side applications, and Kotlin Multiplatform can share code between Android, iOS, desktop, and web targets.

See also

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings