Introduction to Swift

1.1 What is Swift?

A general-purpose, compiled, statically typed programming language created by Apple (Chris Lattner and team). It was introduced at WWDC 2014 and open-sourced in 2015 (swift.org).

Design goals: safe (eliminates whole classes of bugs), fast (LLVM-compiled native code), and expressive (modern, readable syntax).

Multi-paradigm: object-oriented, protocol-oriented, functional, and generic.

1.2 Key Features

Type safety and inference Strong static types with minimal annotations

Explicit handling of missing values (no null pointer surprises)

Powerful structs and enums with copy semantics Protocols + extensions + generics Automatic Reference Counting (ARC)

Deterministic memory management without a garbage collector async/await, actors, structured concurrency, compile-time data-race safety (Swift 6) Closures and higher-order functions

Powerful switch, if case, enums with associated values Compile-time code generation (Swift 5.9+)

Seamless with Objective-C, C, and (since 5.9) C++ Apple platforms, Linux, Windows, Android, embedded, WebAssembly

1.3 Where Swift Is Used

Apple platforms: iOS, iPadOS, macOS, watchOS, tvOS, visionOS apps (SwiftUI, UIKit, AppKit).

Server-side: Vapor, Hummingbird, the Swift on Server ecosystem (Apple uses Swift for services like iCloud Keychain and the Password Monitoring Service).

Embedded systems (Embedded Swift), command-line tools, scripting, machine learning (Core ML, MLX Swift), and cross-platform apps (Skip, Swift on Android).

1.4 Swift vs Other Languages

Static, inferred Rich (struct/enum) data classes (refs) Compile-time (Swift 6)