Est. 2014 Beginner

Swift

Apple's modern programming language for iOS, macOS, watchOS, tvOS, and server-side development, designed for safety, performance, and expressiveness.

Created by Chris Lattner and Apple Inc.

Paradigm Multi-paradigm: Protocol-Oriented, Object-Oriented, Functional
Typing Static, Strong, Inferred
First Appeared 2014
Latest Version Swift 6.0 (2024)

Swift is a modern, general-purpose programming language developed by Apple that combines powerful type inference and pattern matching with a clean, expressive syntax. Since its public release in 2014, Swift has become the dominant language for Apple platform development and is increasingly used for server-side applications.

History & Origins

Swift’s development began in 2010 when Chris Lattner, the creator of the LLVM compiler infrastructure, started working on a new language at Apple. The goal was to create a modern replacement for Objective-C that would be safer, faster, and more approachable for new developers while maintaining full interoperability with existing Objective-C code and Apple’s Cocoa frameworks.

The language was developed in secret for four years before being announced at Apple’s Worldwide Developers Conference (WWDC) in June 2014. In a surprise move, Apple made Swift available immediately, and developers began using it that same day.

The Case Against Objective-C

While Objective-C served Apple well for decades, it carried significant historical baggage:

  • C Heritage: As a superset of C, Objective-C inherited C’s memory safety issues
  • Verbose Syntax: Method calls and property access used bracket notation that many found cumbersome
  • Dynamic Typing: While flexible, dynamic dispatch made it harder to catch errors at compile time
  • Manual Memory Management: Though ARC helped, developers still needed to understand reference cycles

Swift addressed these issues while maintaining Objective-C interoperability, allowing gradual migration of existing codebases.

Design Philosophy

Swift embodies several key design principles:

Safety First

Swift eliminates entire categories of common programming errors:

  • No Null Pointer Exceptions: Optionals make nil values explicit and safe
  • Bounds Checking: Array access is verified at runtime
  • Memory Safety: Automatic Reference Counting (ARC) manages memory
  • Type Safety: Strong typing catches errors at compile time

Performance

Despite its high-level features, Swift compiles to efficient native code:

  • LLVM Backend: Leverages world-class optimization
  • Value Types: Structs and enums avoid heap allocation when possible
  • Copy-on-Write: Efficient handling of large data structures
  • Whole Module Optimization: Cross-function optimization at compile time

Expressiveness

Swift balances power with readability:

  • Clean Syntax: No semicolons required, type inference reduces boilerplate
  • Functional Features: Map, filter, reduce, and higher-order functions
  • Protocol-Oriented: Protocols with default implementations enable composition over inheritance
  • Generics: Type-safe generic programming with constraints

Key Features

Optionals

Swift’s approach to null safety is one of its defining features:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
var name: String? = nil  // Optional String
name = "Swift"

// Safe unwrapping
if let unwrappedName = name {
    print("Hello, \(unwrappedName)")
}

// Optional chaining
let length = name?.count  // Returns Int?

Protocol-Oriented Programming

Swift pioneered protocol-oriented programming as a paradigm:

1
2
3
4
5
6
7
8
9
protocol Describable {
    var description: String { get }
}

extension Describable {
    func printDescription() {
        print(description)
    }
}

Modern Concurrency

Swift 5.5 introduced structured concurrency with async/await:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
func fetchData() async throws -> Data {
    let (data, _) = try await URLSession.shared.data(from: url)
    return data
}

// Actor for safe concurrent state
actor Counter {
    var value = 0
    func increment() { value += 1 }
}

Evolution & Open Source

In December 2015, Apple made Swift open source under the Apache 2.0 license. This decision transformed Swift from an Apple-exclusive technology into a community-driven project.

The Swift Evolution process allows anyone to propose and discuss changes to the language. Major features like async/await, result builders, and property wrappers all went through this public process, resulting in thoroughly vetted designs.

Swift Today

Swift 6.0, released in 2024, represents a major milestone with complete data-race safety at compile time. The language continues to evolve through its open process while maintaining its core values of safety, speed, and expressiveness.

Beyond Apple platforms, Swift runs on Linux, Windows, and is being adopted for:

  • Server Development: Vapor, Hummingbird, and other frameworks
  • Systems Programming: Low-level development with C interoperability
  • WebAssembly: Experimental Swift-to-WASM compilation
  • Cross-Platform Apps: Sharing business logic across platforms

Whether you’re building the next great iOS app, a high-performance server, or exploring modern language design, Swift offers a compelling combination of safety and power.

Timeline

2010
Chris Lattner begins Swift development at Apple
2014
Swift announced at WWDC, immediately available
2015
Swift 2.0 with error handling and protocol extensions
2015
Swift open-sourced under Apache 2.0 license
2016
Swift 3.0 with major API redesign (Swift Evolution)
2017
Swift 4.0 with Codable and String improvements
2019
Swift 5.0 achieves ABI stability
2019
SwiftUI framework introduced for declarative UI
2020
Swift 5.3 with cross-platform support improvements
2021
Swift 5.5 introduces async/await concurrency
2022
Swift 5.7 with distributed actors and regex literals
2024
Swift 6.0 with complete data-race safety

Notable Uses & Legacy

iOS & macOS Applications

Swift is the primary language for developing apps on Apple platforms, used by millions of developers worldwide.

SwiftUI

Apple's declarative UI framework uses Swift's advanced features to enable reactive, cross-platform interface development.

Server-Side Swift

Frameworks like Vapor and Kitura enable building high-performance web services and APIs in Swift.

Machine Learning

Core ML and Create ML frameworks allow Swift developers to integrate and train machine learning models directly.

Lyft & Uber

Both ride-sharing giants rebuilt their iOS apps in Swift for improved performance and maintainability.

LinkedIn

LinkedIn's iOS app is built with Swift, showcasing its enterprise-scale capabilities.

Language Influence

Influenced By

Objective-C Rust Haskell Ruby Python C# CLU

Influenced

Kotlin (some features) Mojo

Running Today

Run examples using the official Docker image:

docker pull swift:6.0

Example usage:

docker run --rm -v $(pwd):/app -w /app swift:6.0 swift hello.swift

Topics Covered

Last updated: