Kotlin — Modern Statically Typed Language for JVM and Beyond
Kotlin is a statically typed, general-purpose programming language developed by JetBrains. Runs on the JVM, Android, native, WebAssembly, and JS targets. Officially endorsed by Google as the preferred language for Android development.
What it is
Kotlin is a statically typed, general-purpose programming language developed by JetBrains. It runs on the JVM, compiles to Android bytecode, native binaries (via Kotlin/Native), WebAssembly, and JavaScript. Google officially endorses Kotlin as the preferred language for Android development.
It is designed for developers who want a modern, concise alternative to Java with null safety, coroutines for async programming, and seamless interop with existing Java codebases.
How it saves time or tokens
Kotlin eliminates common Java boilerplate: data classes replace hundreds of lines of getters, setters, equals, hashCode, and toString. Null safety at the type-system level catches NullPointerExceptions at compile time rather than in production. Coroutines provide structured concurrency without the complexity of threads or callback chains. Extension functions let you add methods to existing classes without inheritance.
How to use
- Install Kotlin via SDKMAN or Homebrew.
curl -s https://get.sdkman.io | bash
sdk install kotlin
- Write and run a simple program.
// Main.kt
data class User(val name: String, val score: Int)
fun main() {
val users = listOf(
User('Alice', 95),
User('Bob', 87),
User('Carol', 91)
)
val top = users.maxByOrNull { it.score }
println('Top: ${top?.name}')
}
kotlinc Main.kt -include-runtime -d main.jar
java -jar main.jar
- For Android, create a new project in Android Studio -- Kotlin is the default language.
Example
Kotlin coroutines for async work:
import kotlinx.coroutines.*
fun main() = runBlocking {
val result = async(Dispatchers.IO) {
// Simulate network call
delay(1000)
'Data loaded'
}
println(result.await())
}
Related on TokRepo
- Coding tools -- Languages, frameworks, and developer tools.
- Automation tools -- Build scripts and CI pipelines that use Kotlin DSLs.
Common pitfalls
- Kotlin compile times are slower than Java for large projects. Use the Kotlin daemon and incremental compilation to mitigate.
- Mixing Kotlin and Java in the same module works but requires attention to nullability annotations on the Java side. Use @Nullable and @NotNull annotations in Java code called from Kotlin.
- Kotlin Multiplatform (KMP) is production-ready for mobile but still evolving for server and desktop targets. Check platform-specific library support before committing.
Frequently Asked Questions
Kotlin is the preferred language for Android development and is widely adopted for server-side JVM projects. However, Java remains dominant in enterprise backends, legacy systems, and frameworks like Spring (which supports both). The two languages coexist and interoperate.
Yes. Kotlin has full interop with Java. You can call Java code from Kotlin and vice versa without wrappers or adapters. Existing Maven and Gradle dependencies work unchanged.
Kotlin Multiplatform (KMP) lets you share business logic across Android, iOS, web, and desktop from a single Kotlin codebase. Platform-specific code is written using expect/actual declarations. The Compose Multiplatform framework extends this to shared UI.
Kotlin distinguishes nullable types (String?) from non-nullable types (String) at the type system level. The compiler enforces null checks, preventing NullPointerExceptions at runtime. You use safe calls (?.), Elvis operator (?:), and not-null assertions (!!) to handle nullable values.
Yes. Kotlin is used with Spring Boot, Ktor (JetBrains' own framework), and other JVM server frameworks. Spring officially supports Kotlin with dedicated DSLs, coroutine integration, and null-safety-aware APIs.
Citations (3)
- Kotlin Official Site— Kotlin is developed by JetBrains and endorsed by Google for Android
- Kotlin Multiplatform Docs— Kotlin Multiplatform for sharing code across platforms
- Android Developers— Google's preferred language for Android development
Related on TokRepo
Discussion
Related Assets
NAPI-RS — Build Node.js Native Addons in Rust
Write high-performance Node.js native modules in Rust with automatic TypeScript type generation and cross-platform prebuilt binaries.
Mamba — Fast Cross-Platform Package Manager
A drop-in conda replacement written in C++ that resolves environments in seconds instead of minutes.
Plasmo — The Browser Extension Framework
Build, test, and publish browser extensions for Chrome, Firefox, and Edge using React or Vue with hot-reload and automatic manifest generation.