← the guideMulticore & Missions

§ 02 — Eras · 2014

Swift

Objective-C’s heir — safe by default, friendly on purpose

Left: era context, features, and the 101 hello. Right: 3 core concepts, 3 deeper 201 lessons, the factorial specimen, and where Swift lives today — each column scrolls on its own.

creators
Chris Lattner, Apple, 2014
status
alive · all Apple platforms, expanding server-side

The problem it solves

Objective-C repelled newcomers and memory bugs persisted. Swift made safety the default and modern syntax the attraction.

The problem it carries

A decade of source-breaking churn, an ABI saga — and gravity: it lives almost entirely inside Apple’s orbit.

Key features

optionals
Nil lives in the type system, and unwrapping is explicit and checked.
value semantics
Structs copy, classes reference — the choice is visible in the declaration.
protocols with associated types
Abstractions without inheritance, expressible without naming a supertype.
whole-module optimization
The compiler sees the entire module, so generics specialize and cross-file calls inline.

101 — hello, world

Session one is the smallest program that still counts as speaking Swift: what every tutorial prints first, in the dialect that mattered when the language arrived (2014).

the first program2014
print("Hello, world")

101First contact — hello world and 3 ideas that define how Swift reads. 201 — 3 lessons on mechanisms you meet after the factorial specimen: the sharp edges practitioners actually use.

101 — core concepts

3 fragments, each naming a habit of mind in Swift. Read the note, then the code — together they are the 101 in one sitting.

01 — optionals

Nil lives in the type system; unwrapping is explicit and checked.

var port: String? = "osaka"

if let p = port {
  print(p.uppercased())   // only runs when non-nil
}

02 — structs & protocols

Value types plus protocols — Swift’s answer to classes-everywhere.

protocol Dockable {
  func dock() -> String
}

struct Ship: Dockable {
  let name: String
  func dock() -> String { "(name) docked" }
}

03 — closures

Shorthand arguments ($0) and key paths make function-valued code terse.

let raised = wages.map { $0 + 5 }
let names = ships.map(\.name)

201 — going deeper

The 201 assumes you have read the 101 and the specimen. Each lesson is one mechanism — what it is for, how it looks in code, and the trap or payoff that makes Swift distinctive at scale.

  1. ARC and retain cycles
  2. protocol composition
  3. structured concurrency

ARC and retain cycles

Automatic reference counting frees memory for you — unless two objects hold each other, which weak and unowned references break.

final class Port {
  weak var city: City?
}

protocol composition

Protocols with associated types constrain what a generic can hold; protocol extensions add default behaviour without inheritance.

protocol Dockable { func dock() }
extension Dockable {
  func dockAndLog() { dock(); print("docked") }
}

structured concurrency

async/await with task groups keeps child tasks scoped to their parent, so cancellation propagates and no task outlives its work.

await withTaskGroup(of: Int.self) { group in
  for port in ports { group.addTask { await fetch(port) } }
  for await value in group { total += value }
}

The specimen — factorial

The optional: null moves into the type system — you cannot forget the nil case, because the compiler will not let you.

the optional2014
var port: String? = "osaka"

if let p = port {
  print(p.uppercased())
}

Run it today

runswift fact.swift

Where it is now

iOS, macOS, visionOS — effectively the floor of the App Store — plus server frameworks like Vapor.