What Is Swift?
Swift is a general-purpose, compiled programming language created by Apple and first released in 2014. It replaced Objective-C as the main language for building apps on Apple's platforms, and it has been open source since 2015, running on macOS, Linux, and Windows.
let name = "Swift"
print("Hello, \(name)!")
Hello, Swift!
Its defining traits:
- Safe by design — Swift catches many mistakes before your program runs. A variable can't be used before it has a value, and a value that might be missing must be marked as such (an optional, covered in its own lesson), so "null" crashes are much rarer.
- Fast — Swift compiles to native machine code, so programs run at speeds close to C and C++.
- Statically typed, with type inference — every value has a fixed
type, but you rarely have to write it: Swift works out that
nameabove is aString. - Modern and expressive — closures, generics, powerful enums, and
built-in
async/awaitconcurrency. - Automatic memory management — Swift frees memory for you using Automatic Reference Counting (ARC), covered in Level 3.