Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Comparative Asynchronous Programming
Search
Ash Furrow
February 24, 2017
Programming
9.9k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Comparative Asynchronous Programming
Presented at Playgrounds Conf:
http://www.playgroundscon.com/
Ash Furrow
February 24, 2017
More Decks by Ash Furrow
See All by Ash Furrow
My Slow Return to a Swift Career
ashfurrow
0
35
Migrating to React Native: A Long-Term Retrospective
ashfurrow
0
360
How Artsy Automates Team Culture
ashfurrow
0
3.5k
Building Custom TSLint Rules
ashfurrow
0
550
Circumventing Fear of the Unknown
ashfurrow
1
620
Building Better Software by Building Better Teams
ashfurrow
1
730
Building Open Source Communities
ashfurrow
0
1.1k
Building Compassionate Software
ashfurrow
0
620
Swift, Briskly
ashfurrow
0
220
Other Decks in Programming
See All in Programming
Performance Optimization With LLMs
xleitix
0
230
Materialが消えた日 〜真っ白なFlutterキャンバスにRenderObjectで絵を描く〜
umigishiaoi
0
120
作って学ぶSpring BootのAuto Configuration / JJUG Night Seminar 2026-10-19
rshindo
0
210
Vapor Mode でアクセシビリティは 壊れないか検証した話
fuqda
1
280
Long Living Tokens, Die, Die, Die! (or: The One Ring is Banned in Modern)
sylph01
0
400
Zero-Tap Sign-In対応、結局何をすればいいの?
mitohato14
0
1.1k
あなたの await、OS まで届いてる? strace で覗く JavaScript の非同期
hasutosasaki
1
1.7k
Kotlinize Is Not Just Converting to Kotlin
chigichan24
1
210
Vue.jsで作る空間解析アプリとCapacitorプラグインのData Bridge
hal_spidernight
1
140
学びを記事・スライド・Xへ高速展開する― AI-assisted Learning Loopで回すコンテンツ生成術
ochtum
0
180
GraphQL の onError と Nullability のこれから
quramy
0
200
PumaからFalconに移行したRailsアプリケーションでの実践
falcon8823
0
310
Featured
See All Featured
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
660
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
2
6.4k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
620
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
910
A Tale of Four Properties
chriscoyier
163
24k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
550
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
2
2.1k
Making the Leap to Tech Lead
cromwellryan
135
10k
The browser strikes back
jonoalderson
0
1.9k
Building AI with AI
inesmontani
PRO
1
1.3k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
330
Transcript
Comparative Asynchronous Programming
None
Agenda 1. Asynchronous programming is hard. 2. Swift already supports
a few async methodologies. 3. Swift supports some other paradigms. 4. But lacks support for others.
Asynchronous Programming: Difficult and Subjective
“Normal” programming
let returnValue = someFunctionCall()
Asynchronous programming
Development is all about tradeoffs
let file = readFile() ... readFile() { file in ...
}
Embrace Tradeoffs
Swift Has Async Built-in. Sorta.
Built-in Async Approaches
Grand Central Dispatch
NSOperationQueue / DRBOperationTree
POSIX Threads
Target / Action
Callbacks / Completion Handlers
logIn(with: credentials) { result in // Handle login success or
failure }
Callback Hell
getCredentialsFromUser() { credentials in logIn(with: credentials) { result in //
Handle login success or failure } }
getCredentialsFromUser() { credentials, error in if credentials { logIn(with: credentials)
{ login, error in if login { // Handle login success } else { // Handle error } } } else { // Handle error } }
(credentials: Credentials?) -> Void (credentials: Credentials?, error: Error?) -> Void
(result: Result<Credentials>) -> Void
enum Result<T> { case success(T) case error(Error) }
Callback Heaven
Some Async Abstractions are Supported in Swift
Promises & Futures
getCredentialsFromUser() .flatMap { credentials in return login(with: credentials) } .onSuccess
{ login in // Handle login success } .onFailure { error in // Handle login error }
Functional Reactive Programming
getCredentialsFromUser() .flatMap { credentials in return login(with: credentials) } .on(next:
{ login in // Handle login success }, error: { error in // Handle login error })
None
gerstureRecognizer.rx .event .map { recognizer in return recognizer.location(in: recognizer.view) }
.bind(to: circle.rx.center)
Actor Model
None
Actor Model
Some Async Abstractions are Impossible in Swift
Async / Await
async func logIn() -> Login { let credentials = await
getCredentialsFromUser() return await logIn(with: credentials) }
Coroutines and Generator Functions
func fibGenerator*() -> Int { var i = 0, j
= 1 repeat { let next = i + j yield next (i, j) = (j, next) } while true } fibGenerator() // returns 1 fibGenerator() // returns 2 fibGenerator() // returns 3 fibGenerator() // returns 5
Wrap Up 1. There’s no “right way” to do async
programming. 2. Asynchronous abstractions built into Swift aren’t great. 3. There are some cool things you can do in Swift. 4. There are other cool things that you can’t do in Swift.
None