{
  "schema_version": "1.0",
  "codex": "thecodex.expert/coding",
  "type": "language-reference",
  "slug": "languages/swift",
  "name": "Swift",
  "section": "Languages",
  "canonical_definition": "Swift is a statically typed, compiled, multi-paradigm programming language created by Apple that replaces Objective-C for iOS, macOS, watchOS, and visionOS development \u2014 providing optionals for null safety, value semantics, protocol-oriented programming, async/await with actors, and ARC memory management with no garbage collector.",
  "confidence": "high",
  "last_verified": "2026-06-01",
  "url": "https://thecodex.expert/coding/languages/swift/",
  "current_version": "Swift 5.10 / 6.0 (2024)",
  "released": "June 2014 (WWDC); open-sourced December 2015",
  "creator": "Chris Lattner (Apple)",
  "typing": "static, type-inferred",
  "memory_management": "ARC (Automatic Reference Counting) \u2014 not GC; deterministic deallocation",
  "platforms": [
    "iOS",
    "macOS",
    "watchOS",
    "tvOS",
    "visionOS",
    "Linux",
    "Windows"
  ],
  "replaces": "Objective-C; 100% interoperable via bridging header",
  "paradigms": [
    "object-oriented",
    "protocol-oriented",
    "functional",
    "procedural"
  ],
  "key_features": {
    "optionals": "T = non-nil; T? = optional; if let, guard let, ??, ?., !, .map \u2014 compiler-enforced nil handling",
    "value_types": "struct and enum are value types (copied); class is reference type (shared)",
    "protocols": "Define contracts; protocol extensions provide default implementations; protocol-oriented programming",
    "arc": "Automatic Reference Counting \u2014 deterministic; weak (nil on dealloc) and unowned (crash on dealloc after) to break cycles",
    "async_await": "Swift 5.5+ (2021); async/await, Task, TaskGroup, structured concurrency",
    "actors": "Reference types that serialise mutable state access; @MainActor for UI thread; compile-time actor isolation",
    "swiftui": "Declarative UI framework (2019); View = struct; @State, @StateObject, @Binding, @EnvironmentObject"
  },
  "critical_notes": {
    "struct_vs_class": "struct = value type (copied on assignment); class = reference type (shared on assignment)",
    "force_unwrap_crash": "! force-unwrap crashes with fatal error if nil; use if let / guard let / ?? instead",
    "arc_not_gc": "ARC is NOT garbage collection \u2014 retain/release inserted at compile time; deterministic deallocation",
    "reference_cycles": "Strong reference cycles prevent deallocation; break with weak (auto-nil) or unowned (crash after dealloc)",
    "objc_coexistence": "Swift and Objective-C can coexist in same project via bridging header; no rewrite needed"
  },
  "abi_stability": "Swift 5.0 (2019) \u2014 binary compatibility between compiler versions on Apple platforms; runtime bundled with OS (iOS 12.2+, macOS 10.14.4+)",
  "sources": [
    {
      "num": 1,
      "citation": "Apple Inc. The Swift Programming Language. docs.swift.org/swift-book/.",
      "tier": 1
    },
    {
      "num": 2,
      "citation": "Apple Inc. Swift API Design Guidelines. swift.org/documentation/api-design-guidelines/.",
      "tier": 1
    },
    {
      "num": 3,
      "citation": "Swift Evolution. github.com/apple/swift-evolution.",
      "tier": 1
    },
    {
      "num": 4,
      "citation": "Apple Inc. SwiftUI documentation. developer.apple.com/documentation/swiftui/.",
      "tier": 1
    },
    {
      "num": 5,
      "citation": "Lattner, C. Swift's origin and design goals. chris.lattner.com.",
      "tier": 1
    }
  ]
}