Swift
A general-purpose, statically typed, multi-paradigm programming language developed by Apple as a replacement for Objective-C across the Apple platforms. Open-source under the Apache 2.0 licence since 2015.
- Paradigms
- imperative · OOP · functional
- Typing
- static
- Memory
- arc
- Version
- 6.0
- First released
- 2014
Swift is a general-purpose, statically typed, multi-paradigm programming language developed by Apple as a successor to Objective-C across the Apple platforms — iOS, iPadOS, macOS, watchOS, tvOS, and visionOS. The language combines features from a lineage that includes Objective-C, Rust, Haskell, Ruby, and Python: strong static typing with type inference, value types as the default for the standard library’s data structures, optionals as a first-class encoding of nullability, generics with associated types, protocols with default implementations, and pattern matching. Memory is managed by Automatic Reference Counting (ARC) rather than by a tracing garbage collector — references hold a count that is adjusted as the reference is copied or destroyed, and the referenced object is deallocated when the count reaches zero. The compiler is built on LLVM and produces native machine code; there is no virtual machine. Concurrency is structured: Swift 5.5 introduced async/await, structured tasks, and actors as the language-level mechanism for isolating mutable state.
History
Swift was begun by Chris Lattner as an internal Apple project in July 2010 and was developed by a team at Apple in parallel with a substantial body of Objective-C work that pre-dated and continues to surround it. The language was announced at the Apple Worldwide Developers Conference in June 2014 and released alongside Xcode 6 the same year. Apple released Swift as an open-source project under the Apache 2.0 licence in December 2015, transferring development to a public repository hosted at swift.org and establishing the Swift Evolution process for community-driven proposals. Major revisions: Swift 3 (2016) was a substantial syntactic overhaul that broke source compatibility with prior versions; Swift 4 (2017) introduced the Codable protocol; Swift 5 (2019) stabilised the application binary interface, permitting future Swift releases to load against earlier compiled binaries; Swift 5.5 (2021) introduced the structured-concurrency model — async/await, Task, and actor — that has come to define modern Swift; Swift 6 (2024) introduced strict concurrency checking by default, closing a long-standing class of data-race defects through compile-time enforcement.
Hello world
print("Hello, world!")
Compilation and execution with the standard toolchain:
swiftc hello.swift -o hello && ./hello
Direct execution of a Swift source file is also supported:
swift hello.swift
The conventional development environment for application work is Xcode, Apple’s integrated development environment for the Apple platforms. For command-line and server-side work, the Swift Package Manager (SwiftPM) provides cross-platform project organisation, dependency resolution, and build orchestration:
swift package init --type executable
swift run
Server-side use of Swift is increasing through frameworks such as Vapor and Hummingbird, both of which build on the official SwiftNIO networking library. The toolchain is available on macOS, Linux, and Windows; the language is governed jointly by Apple and the Swift Steering Group, with technical proposals reviewed publicly through Swift Evolution.