# Introduction to the Swift programming language

> An introduction to Swift, the statically typed, compiled language Apple created in 2014 to build apps for iOS, iPadOS, watchOS, macOS, and beyond.

Author: [Flavio Copes](https://flaviocopes.com/about/) | Published: 2021-05-18 | Updated: 2026-07-18 | Topics: [Swift](https://flaviocopes.com/tags/swift/) | Canonical: https://flaviocopes.com/swift-introduction/

> This post is the beginning of a new series on Swift

Swift is a general-purpose programming language created by Apple and introduced in 2014.

It is the main language used to build new applications across Apple platforms. It also runs on Linux and Windows, and people use it for servers, command-line tools, and cross-platform packages.

Swift is open source, compiled, and statically typed.

This is a complete Swift program:

```swift
let name = "Flavio"
print("Hello \(name)")
```

The [Swift language guide](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/) is the authoritative reference for the language.

## Swift is statically typed

Every value in Swift has a type. The compiler checks those types before it builds the program.

You can write the type explicitly:

```swift
let score: Int = 10
```

Swift can often infer it:

```swift
let score = 10
```

In both examples, `score` is an `Int`.

Swift is also type-safe. For example, you cannot pass a `String` to a function that requires an `Int`.

Optionals make the absence of a value explicit:

```swift
var nickname: String? = nil
```

The `?` tells us that `nickname` can contain a string or no value. Swift then makes us handle both cases safely.

See [The Basics](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/thebasics/) for the official explanation of types, constants, variables, and optionals.

## Where can you use Swift?

Swift is closely associated with Apple platforms, but it is not limited to them.

The official [Swift platform support page](https://www.swift.org/platform-support/) lists macOS, Linux distributions, and Windows as development platforms. A Swift toolchain includes the compiler, standard library, Swift Package Manager, and development tools for the supported platform.

On a Mac, Xcode includes everything needed to build applications for Apple platforms. Xcode also gives you a visual interface builder, simulator, debugger, and code completion.

Swift Package Manager handles dependencies and builds Swift packages. It is part of the Swift toolchain, not an extra package manager you have to install separately.

## How to start learning Swift

If you use a Mac or iPad, [Swift Playground](https://developer.apple.com/swift-playground/) is a friendly place to begin. You can run small pieces of Swift without creating a complete application first.

On a Mac, install Xcode when you are ready to build an app.

On Linux or Windows, follow the official [Swift getting started guide](https://www.swift.org/getting-started/) to install the correct toolchain.

After installing a toolchain, create a small executable package:

```bash
mkdir HelloSwift
cd HelloSwift
swift package init --type executable
swift run
```

This creates a Swift Package Manager project and runs it.

The goal of this series is to get you comfortable with Swift from zero. Continue with:

- [Variables](https://flaviocopes.com/swift-variables/)
- [Objects](https://flaviocopes.com/swift-objects/)
- [Basic Operators](https://flaviocopes.com/swift-operators/)
- [`if` conditionals](https://flaviocopes.com/swift-conditionals-if/)
- [`switch` conditionals](https://flaviocopes.com/swift-conditionals-switch/)
- [Ternary conditionals](https://flaviocopes.com/swift-conditionals-ternary-operator/)
- [`for-in` loops](https://flaviocopes.com/swift-loops-for-in/)
- [`while` loops](https://flaviocopes.com/swift-loops-while/)
- [`repeat-while` loops](https://flaviocopes.com/swift-loops-repeat-while/)
- [Loop control transfer statements](https://flaviocopes.com/swift-loops-control-transfer/)
- [Comments](https://flaviocopes.com/swift-comments/)
- [Semicolons](https://flaviocopes.com/swift-semicolons/)
- [Numbers](https://flaviocopes.com/swift-numbers/)
- [Strings](https://flaviocopes.com/swift-strings/)
- [Booleans](https://flaviocopes.com/swift-booleans/)
- [Arrays](https://flaviocopes.com/swift-arrays/)
- [Sets](https://flaviocopes.com/swift-sets/)
- [Dictionaries](https://flaviocopes.com/swift-dictionaries/)
- [Tuples](https://flaviocopes.com/swift-tuples/)
- [nil and Optionals](https://flaviocopes.com/swift-optionals-nil/)
- [Enums](https://flaviocopes.com/swift-enumerations/)	
- [Structs](https://flaviocopes.com/swift-structures/)
- [Classes](https://flaviocopes.com/swift-classes/)
- [Functions](https://flaviocopes.com/swift-functions/)
- [Protocols](https://flaviocopes.com/swift-protocols/)
