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
2.7k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
830
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
DynamoDBの基礎を振り返りながらベクトル検索機能を理解する
musan
3
240
ソフトウェアエンジニアにとっての生成AI - 特性を知って使い倒す / generative ai for software enginner
kishida
7
2.2k
How I Won Prize Money at a Hackathon Using Codex and Symphony Alpha
yasei_no_otoko
0
130
Webエンジニアなのにブラウザの仕組みがわからないので、Pythonで自作してみた
tatsuki12
4
1.1k
in-process GraphQL のすすめ #ginzajs
izumin5210
4
1.5k
AI Engineeringは、AIプロダクトだけのものか? 〜AIがソフトウェアを作る時代の新しい当たり前〜 / No AI in your product. AI Engineering in your development.
rkaga
5
550
Go を使い始めて 2 ヶ月の学び / My first two months with Go
contour_gara
0
390
自動化したのに回らない テスト運用の壁―AI時代の品質責任と生産性
mfunaki
0
530
属人化した知識を、 AIが辿れる地図にする
pkshadeck
PRO
1
220
業務時間外もAIに働いてもらう話
colorful12
2
8.7k
<title><a id="</title>君はこのHTMLをパースできるか"></a></title> #雑LT_study
pizzacat83
0
180
わからない話を追いかけたら、プログラミング言語を作る側にいた
ydah
3
560
Featured
See All Featured
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
430
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
400
HDC tutorial
michielstock
2
820
Code Reviewing Like a Champion
maltzj
528
40k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.4k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
220
The untapped power of vector embeddings
frankvandijk
2
1.8k
The Spectacular Lies of Maps
axbom
PRO
1
950
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
630
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
450
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
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?