Swift is Apple's general-purpose programming language, built from the ground up for safety, speed and readability. If you want to ship an app on iOS, iPadOS, macOS, watchOS or tvOS, Swift is the language Apple expects you to reach for.
Why Apple made a new language
Before Swift, Apple developers wrote Objective-C, a language that dates back to the 1980s. Objective-C works, but its syntax is verbose, its error messages can be cryptic, and it leaves many mistakes for the programmer to catch at run time. Swift, released in 2014, was designed to fix those problems: cleaner syntax, stronger compile-time checks and modern features such as type inference, closures and generics.
Swift is also open source. The compiler, standard library and package manager all live on swift.org, and the language runs on Linux and Windows too, not only on Apple platforms.
The basics: variables, functions and control flow
Swift's syntax reads almost like English. A variable is declared with var, a constant with let, and the compiler infers the type when it can:
var fish = "tuna" // String, inferred
let lives = 9 // Int, constantFunctions use the func keyword, and named parameters make call sites read clearly:
func greet(name: String) -> String {
return "Hello, \(name)!"
Wondering how this was made? How we make these