🐦 Swift
What is Swift?
Swift is Apple's modern, powerful programming language used to build apps for iOS, macOS, watchOS, and tvOS. It's designed to be safe, fast, and expressive — making it the go-to language for Apple platform development.
Archon is built entirely in Swift. Learning Swift is the first step toward understanding how your app works under the hood.
Why Swift?
- → Type safe — Swift catches type errors at compile time, preventing many common bugs before your code ever runs.
- → Modern syntax — Clean and readable, making it easier to write and maintain code.
- → Performance — Compiled language that runs fast, comparable to C++.
- → Interoperable — Works seamlessly with existing Objective-C code.
Constants and Variables
Swift uses let for constants and var for variables. Constants are values that never change — and Swift encourages you to use them whenever possible.
Editor
Swift
Output
Try it
Change the value of name and downloads in the editor. Notice how string interpolation with \() embeds values directly into strings.
Basic Types
// Strings — text values
let city = "San Francisco"
// Integers — whole numbers
let age = 28
// Doubles — decimal numbers
let temperature = 72.5
// Booleans — true or false
let isLoggedIn = true
// Type annotations (explicit types)
let population: Int = 850_000
let rating: Double = 4.8
Quiz
Which keyword declares a constant in Swift?
Challenge
Create constants for your name and age, then print them with string interpolation using \().