Kotlin is a general-purpose, statically typed language for the JVM and other targets. It emphasizes concise code, compile-time checking, practical tooling, and unrestricted Java interoperability. Its design supports object-oriented and functional styles without forcing either one, making it suitable for new applications and gradual adoption inside existing Java systems. section 1.0 section 1.2 section 1.4.4
Listing 1.1 An early taste of Kotlin
data class Person( #1
val name: String, #2
val age: Int? = null #3
)
fun main() { #4
val persons = listOf(
Person("Alice", age = 29), #5
Person("Bob"), #6
)
val oldest = persons.maxBy { #7
it.age ?: 0 #8
}
println("The oldest is: $oldest") #9
}
// The oldest is: Person(name=Alice, age=29) #10
This compact program defines immutable-looking person data, models an optional age, and selects the oldest entry without Java-style boilerplate. section 1.1
The example combines several everyday features: data classes declare properties in their constructor, val creates a read-only reference, top-level functions need no enclosing class, and named arguments make calls clearer. The nullable type Int? records that an age may be absent; ?: supplies zero only for the comparison. String templates and collection operations keep the program direct while preserving its intent. section 1.1 section 1.4.3
Kotlin’s central trade-offs favor reliability and maintainability without demanding verbose annotations:
- Static typing lets the compiler verify member access and type consistency before execution; type inference omits declarations when context already determines a type. section 1.2.2
- Nullable and non-null types distinguish values that may be absent, preventing many null-pointer failures at compile time and providing concise null-handling operations. section 1.4.3
- First-class functions, lambdas, immutable values, and pure functions support concise abstractions, safer concurrency, and isolated tests. section 1.2.3
- Data-class properties, inferred types, standard-library operations, and omitted semicolons remove common boilerplate while retaining readable syntax. section 1.4.2
Kotlin and Java can coexist in the same project. Kotlin code can call Java methods, extend Java classes, implement interfaces, and use Java annotations; Java can call Kotlin classes and methods as regular Java APIs. Kotlin collections use Java standard-library classes with added conveniences, avoiding wrapper conversions at API boundaries. IDE navigation, debugging, and refactoring can cross the language boundary. section 1.4.4 section 1.3.1
Server and Android development
On the server, Kotlin can expose JSON over HTTP through Spring Boot annotations or use Ktor’s routing DSL. On Android, Kotlin is the primary language for development tools and libraries; Compose code can keep UI state in ordinary Kotlin functions and conditionally render details after a click. These uses pair shorter code with null-aware type checking in production-oriented applications. section 1.3.1 section 1.3.2
Beyond the JVM, Kotlin can compile to JavaScript for browsers and Node.js, native binaries for iOS and other platforms, and a developing WebAssembly target. Kotlin Multiplatform separates shared code from platform-specific implementations through expect/actual, allowing shared business logic without restricting access to native platform capabilities. section 1.3.3
To experiment, run short programs in the Kotlin online playground. For fuller development, IntelliJ IDEA and Android Studio include Kotlin support. Kotlin/JVM source files use the .kt extension and compile into JVM .class files; command-line builds can package the Kotlin runtime in a JAR before running it with Java. section 1.5.1 section 1.5.2

