{
  "schema_version": "1.0",
  "codex": "thecodex.expert/coding",
  "type": "language-reference",
  "slug": "languages/kotlin",
  "name": "Kotlin",
  "section": "Languages",
  "canonical_definition": "Kotlin is a statically typed, multi-platform programming language developed by JetBrains that compiles to JVM bytecode, JavaScript, and native code \u2014 offering null safety, concise syntax, 100% Java interoperability, and coroutines for asynchronous programming, and is Google's preferred language for Android development.",
  "confidence": "high",
  "last_verified": "2026-06-01",
  "url": "https://thecodex.expert/coding/languages/kotlin/",
  "current_version": "Kotlin 2.x (2024)",
  "released": "February 2016 (1.0)",
  "creator": "JetBrains",
  "compilation_targets": [
    "JVM bytecode",
    "JavaScript (Kotlin/JS)",
    "Native/LLVM (Kotlin/Native)"
  ],
  "typing": "static, null-safe",
  "java_interop": "100% bidirectional",
  "android_status": "Google preferred language since 2019; first-class since 2017",
  "paradigms": [
    "object-oriented",
    "functional",
    "procedural"
  ],
  "key_features": {
    "null_safety": "String is non-null; String? is nullable; safe call ?., Elvis ?:, smart cast after null check",
    "data_classes": "data class generates equals/hashCode/toString/copy/componentN automatically",
    "extension_functions": "Add methods to existing classes without inheritance; resolved statically",
    "sealed_classes": "Restrict class hierarchy; enables exhaustive when expressions (compiler-verified)",
    "coroutines": "Suspendable computations; structured concurrency; not OS threads; CPS-transformed at compile time",
    "val_vs_var": "val = immutable reference (like final); var = mutable; val \u2260 immutable object",
    "smart_cast": "After null/type check, compiler auto-narrows type \u2014 no explicit cast needed",
    "inline_reified": "inline + reified: generic type available at runtime (bypasses JVM type erasure)"
  },
  "critical_notes": {
    "val_not_immutable": "val = immutable reference, not immutable object; val list = mutableListOf() \u2014 list is still mutable",
    "coroutines_not_threads": "Coroutines are NOT threads \u2014 suspendable via CPS; millions on few threads",
    "kotlin_java_coexist": "Kotlin and Java files can coexist in the same project \u2014 bidirectional interop",
    "nullable_distinct": "String and String? are distinct types; null not allowed in non-nullable type",
    "sealed_same_file": "All direct subclasses of a sealed class must be in the same package/compilation unit"
  },
  "kotlin_multiplatform": "Stable since November 2023; shares business logic across Android, iOS, web, desktop; not UI",
  "sources": [
    {
      "num": 1,
      "citation": "JetBrains. Kotlin Language Specification. kotlinlang.org/spec/.",
      "tier": 1
    },
    {
      "num": 2,
      "citation": "JetBrains. Kotlin documentation. kotlinlang.org/docs/.",
      "tier": 1
    },
    {
      "num": 3,
      "citation": "JetBrains. Kotlin coroutines guide. kotlinlang.org/docs/coroutines-guide.html.",
      "tier": 1
    },
    {
      "num": 4,
      "citation": "Jemerov, D. & Isakova, S. (2017). Kotlin in Action. Manning Publications.",
      "tier": 1
    },
    {
      "num": 5,
      "citation": "JetBrains. Kotlin Multiplatform Stable. blog.jetbrains.com, November 2023.",
      "tier": 1
    }
  ]
}