# 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. ## Install Save the content below to `.claude/skills/` or append to your `CLAUDE.md`: ## Quick Use ```bash # Install via SDKMAN curl -s https://get.sdkman.io | bash sdk install kotlin # Or via Homebrew brew install kotlin kotlinc -version kotlin -version ``` Hello world: ```kotlin // Main.kt fun main() { val users = listOf( User("Alice", 95), User("Bob", 87), User("Carol", 91), ) val topUser = users.maxByOrNull { it.score } println("Top: ${topUser?.name}") users .sortedByDescending { it.score } .forEach { println("${it.name}: ${it.score}") } } data class User(val name: String, val score: Int) ``` ```bash kotlinc Main.kt -include-runtime -d main.jar java -jar main.jar ``` Gradle (most common): ```kotlin // build.gradle.kts plugins { kotlin("jvm") version "2.0.0" application } dependencies { implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0") } application { mainClass.set("MainKt") } ``` ## Intro Kotlin is a statically typed, general-purpose programming language developed by JetBrains. Kotlin compiles to Java bytecode (JVM), JavaScript, WebAssembly, and native binaries. Officially endorsed by Google as a preferred language for Android development in 2017. Now the #1 language for new Android apps and widely used on the server (Spring Boot + Kotlin, Ktor) and multiplatform (Kotlin Multiplatform). - **Repo**: https://github.com/JetBrains/kotlin - **Stars**: 52K+ - **License**: Apache 2.0 ## What Kotlin Does - **Null safety** — types distinguish nullable (`String?`) from non-null (`String`) - **Data classes** — auto-generate equals, hashCode, copy - **Extension functions** — add methods to existing classes - **Coroutines** — structured concurrency with suspend functions - **Smart casts** — compiler narrows types after checks - **Type inference** — minimal explicit typing - **Functional** — higher-order, lambdas, collections DSL - **Multiplatform** — share code across JVM, JS, Native, iOS, Android - **Compose** — Jetpack Compose (Android) and Compose Multiplatform (desktop/web/iOS) - **Full Java interop** — call Java from Kotlin and vice versa ## Architecture Kotlin compiler targets JVM bytecode by default (also JS, Native via LLVM, WASM). The Kotlin Multiplatform toolchain compiles shared code for multiple targets. Coroutines are implemented as a compiler transform + runtime library — no OS thread per coroutine. ## Self-Hosting Language toolchain. ## Key Features - Null safety in the type system - Data classes - Extension functions - Coroutines (structured concurrency) - Higher-order functions and lambdas - Operator overloading - Sealed classes + when expressions - Kotlin Multiplatform - Jetpack Compose (Android UI) - Compose Multiplatform (desktop + iOS) - Gradle Kotlin DSL ## Comparison | Language | Target | Null Safety | Coroutines | |---|---|---|---| | Kotlin | JVM/JS/Native | Yes | Yes | | Java | JVM | Optional | Project Loom | | Scala | JVM | Option type | Yes | | Swift | Native | Yes | async/await + actors | | C# | CLR | Nullable ref types | async/await | | Go | Native | No | Goroutines | ## FAQ **Q: Compared to Java?** A: Kotlin is Java's improved version: null safety, data classes, lambdas, extension functions, coroutines, and less boilerplate. Most Java projects can gradually migrate to Kotlin, and the two languages can coexist in the same project. **Q: Must I use Kotlin for Android?** A: Not required, but Google strongly recommends it. Since 2019, new APIs, official docs, and Android KTX are Kotlin-first. **Q: Is Compose Multiplatform mature?** A: In 2024, Desktop and Android are stable, iOS is gradually stabilizing, and Web is still maturing. Usable for production but evaluate against your own needs. ## Sources - Docs: https://kotlinlang.org/docs - GitHub: https://github.com/JetBrains/kotlin - License: Apache 2.0 --- Source: https://tokrepo.com/en/workflows/kotlin-modern-statically-typed-language-jvm-beyond-7cce7cf5 Author: Script Depot