Swift (programming language)
Swift is a high-level general-purpose, multi-paradigm, compiled programming language developed by Apple Inc. and the open-source community. Swift compiles to machine code, as it is an LLVM-based compiler. Swift was first released in June 2014,[11] and the Swift toolchain has shipped in Xcode since version 6, released in 2014.
This article is about the Apple programming language. For the scripting language, see Swift (parallel scripting language). For the CPU core, see Apple A6.Paradigm
Chris Lattner, Doug Gregor, John McCall, Ted Kremenek, Joe Groff, and Apple Inc.[1]
Apple Inc. and open-source contributors
June 2, 2014[2]
Apache License 2.0 (Swift 2.2 and later)
Proprietary (up to Swift 2.2)[4][5]
.swift, .SWIFT
Apple intended Swift to support many core concepts associated with Objective-C, notably dynamic dispatch, widespread late binding, extensible programming, and similar features, but in a "safer" way, making it easier to catch software bugs; Swift has features addressing some common programming errors like null pointer dereferencing and provides syntactic sugar to help avoid the pyramid of doom. Swift supports the concept of protocol extensibility, an extensibility system that can be applied to types, structs and classes, which Apple promotes as a real change in programming paradigms they term "protocol-oriented programming"[12] (similar to traits and type classes).[13]
Swift was introduced at Apple's 2014 Worldwide Developers Conference (WWDC).[14] It underwent an upgrade to version 1.2 during 2014 and a major upgrade to Swift 2 at WWDC 2015. Initially a proprietary language, version 2.2 was made open-source software under the Apache License 2.0 on December 3, 2015, for Apple's platforms and Linux.[15][16]
Through version 3.0 the syntax of Swift went through significant evolution, with the core team making source stability a focus in later versions.[17][18] In the first quarter of 2018 Swift surpassed Objective-C in measured popularity.[19]
Swift 4.0, released in 2017, introduced several changes to some built-in classes and structures. Code written with previous versions of Swift can be updated using the migration functionality built into Xcode. Swift 5, released in March 2019, introduced a stable binary interface on Apple platforms, allowing the Swift runtime to be incorporated into Apple operating systems. It is source compatible with Swift 4.[20]
Swift 5.1 was officially released in September 2019. Swift 5.1 builds on the previous version of Swift 5 by extending the stable features of the language to compile-time with the introduction of module stability. The introduction of module stability makes it possible to create and share binary frameworks that will work with future releases of Swift.[21]
Swift 5.5, officially announced by Apple at the 2021 WWDC, significantly expands language support for concurrency and asynchronous code, notably introducing a unique version of the actor model.[22]
Swift 5.9, was released in September 2023 and includes a macro system, generic parameter packs, and ownership features like the new consume
operator.[23]
The current version, Swift 5.10, was released in March 2024. This version improves the language's concurrency model, allowing for full data isolation to prevent data races. It is also the last release before Swift 6.[24]
Swift is considered a C family programming language and is similar to C in various ways:
It also has similarities to Objective-C:
Differences from Objective-C include:
Development and other implementations[edit]
Because Swift can run on Linux, it is sometimes also used as a server-side language.[102] Some web frameworks have already been developed, such as IBM's Kitura (now discontinued), Perfect and Vapor.
An official "Server APIs" work group has also been started by Apple,[103] with members of the Swift developer community playing a central role.[104]
A second free implementation of Swift that targets Cocoa, Microsoft's Common Language Infrastructure (.NET Framework, now .NET), and the Java and Android platform exists as part of the Elements Compiler from RemObjects Software.[105]
Subsets of Swift have been ported to additional platforms, such as Arduino[106] and Mac OS 9.[107]