Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Jack Nutting | let swift = Race?
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Swift Summit
March 22, 2015
Programming
1
2.7k
Jack Nutting | let swift = Race?
Presented at
www.swiftsummit.com
Swift Summit
March 22, 2015
Tweet
Share
More Decks by Swift Summit
See All by Swift Summit
Marcin Krzyżanowski | CryptoSwift: Crypto You Can Do
swiftsummit
0
25k
Radek Pietruszewski | Swifty Methods
swiftsummit
2
7.6k
Gem Barrett | View from the Other Side
swiftsummit
0
1.5k
Colin Eberhardt | ReactiveCocoa and Swift: Better Together
swiftsummit
3
14k
Joseph Lord | How Swift is Swift?
swiftsummit
2
31k
Al Skipp | The Monad Among Us
swiftsummit
3
800
Al Skipp | The Monad Among Us
swiftsummit
1
4.1k
Brian Gesiak | Swift API Design: Getting Results
swiftsummit
0
7.3k
Anthony Levings | JSON, Swift and Type Safety: It's a wrap
swiftsummit
2
19k
Other Decks in Programming
See All in Programming
Smart Handoff/Pickup ガイド - Claude Code セッション管理
yukiigarashi
0
120
SourceGeneratorのススメ
htkym
0
190
CSC307 Lecture 03
javiergs
PRO
1
490
AI Agent Tool のためのバックエンドアーキテクチャを考える #encraft
izumin5210
6
1.8k
FOSDEM 2026: STUNMESH-go: Building P2P WireGuard Mesh Without Self-Hosted Infrastructure
tjjh89017
0
140
フロントエンド開発の勘所 -複数事業を経験して見えた判断軸の違い-
heimusu
7
2.8k
AgentCoreとHuman in the Loop
har1101
5
220
2026年 エンジニアリング自己学習法
yumechi
0
130
Vibe Coding - AI 驅動的軟體開發
mickyp100
0
170
AIエージェント、”どう作るか”で差は出るか? / AI Agents: Does the "How" Make a Difference?
rkaga
4
2k
360° Signals in Angular: Signal Forms with SignalStore & Resources @ngLondon 01/2026
manfredsteyer
PRO
0
110
Apache Iceberg V3 and migration to V3
tomtanaka
0
140
Featured
See All Featured
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.1k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
280
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.3k
Skip the Path - Find Your Career Trail
mkilby
0
52
Optimising Largest Contentful Paint
csswizardry
37
3.6k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
1.9k
What does AI have to do with Human Rights?
axbom
PRO
0
2k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
110
How to Get Subject Matter Experts Bought In and Actively Contributing to SEO & PR Initiatives.
livdayseo
0
59
Into the Great Unknown - MozCon
thekraken
40
2.2k
Testing 201, or: Great Expectations
jmmastey
46
8k
Speed Design
sergeychernyshev
33
1.5k
Transcript
let swift: Race? Jack Nutting @jacknutting
[email protected]
let swift: Race?
struct Sun { let swift: Race?
let strong: Battle? let wise: Bread? let intelligent: Riches? let knowledgeable: Favor? init() { swift = TimeAndChance() ? Race() : .None strong = TimeAndChance() ? Battle() : .None wise = TimeAndChance() ? Bread() : .None intelligent = TimeAndChance() ? Riches() : .None knowledgeable = TimeAndChance() ? Favor() : .None } }
let swift: Race?
None
[[somePeople like:ObjectiveC] evenIn:2015]
[[[[[[receiver method] method] method] method] method]
method]; receiver.method().method().method() .method().method().method()
Static fixed, stable, steady, consistent motionless, frozen, inert, lifeless
enum
enum Button { case Rectangular(bounds: CGRect,
title: String, font: UIFont) case RoundedCorners(bounds: CGRect, title: String, font: UIFont, radius: CGFloat) }
extension Button { func draw() {
switch self { case let .Rectangular(bounds, title, font): drawRectangleButton(bounds, title, font) case let .RoundedCorners(bounds, title, font, radius): drawRoundedRectangleButton(bounds, title, font, radius) } } }
extension Button { func buttonOfPreferredSize() -‐>
CGSize { switch self { case let .Rectangular(bounds, title, font): return preferredSizeForRectangleButton(bounds, title, font) case let .RoundedCorners(bounds, title, font, radius): return preferredSizeForRoundedRectangleButton(bounds, title, font, radius) } } }
• My Way or the Highway • Eternal Vigilance •
Boilerplate
If a huge chunk of your enum’s code is just
switching on the type, maybe you should just use a set of classes.
Using struct instead of class Marking classes as final Marking
methods as final
Future developers will want the flexibility to extend your system
in ways you can’t foresee.
–Sir Tony Hoare “Premature optimization is the root of all
evil.”
C++
–Jack Nutting “All of C++ is premature optimization.”
Functional Programming is not a silver bullet
http://chris.eidhof.nl/ posts/lenses-in-swift.html
https://www.destroyallsoftware.com/ talks/boundaries
Conclusions Sometimes enums aren’t the answer. Static has drawbacks. All
of C++ is premature optimization. FP is not a silver bullet.
Jack Nutting @jacknutting
[email protected]
let swift: Race?