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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Swift Summit
March 22, 2015
Programming
2.7k
1
Share
Jack Nutting | let swift = Race?
Presented at
www.swiftsummit.com
Swift Summit
March 22, 2015
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.6k
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
810
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
mruby on C#: From VM Implementation to Game Scripting (RubyKaigi 2026)
hadashia
2
1.7k
Programming with a DJ Controller — not vibe coding
m_seki
3
810
Surviving Black Friday: 329 billion requests with Falcon!
ioquatix
0
2.9k
Cache-moi si tu peux : patterns et pièges du cache en production - Devoxx France 2026 - Conférence
slecache
0
340
2026年のソフトウェア開発を考える(2026/05版) / Software Engineering Scrum Fest Niigata 2026 Edition
twada
PRO
22
12k
Symfony AI in Action - SymfonyLive Berlin 2026
chr_hertel
1
130
ついに来た!本格的なマルチクラウド時代の Google Cloud
maroon1st
0
400
過去のレビュー知見をSkillsで資産化した話
pkshadeck
PRO
1
1.7k
From Formal Specification to Property Based Test
ohbarye
0
2.4k
Kingdom of the Machine
yui_knk
2
1.5k
ハーネスエンジニアリングとは?
kinopeee
13
6.9k
Structured Concurrency, Scoped Values and Joiners in the JDK 25 26 27
josepaumard
1
150
Featured
See All Featured
What does AI have to do with Human Rights?
axbom
PRO
1
2.1k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
110
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
3k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
360
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
190
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.2k
Building Applications with DynamoDB
mza
96
7k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
180
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?