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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
40
Migrating to React Native: A Long-Term Retrospective
ashfurrow
0
370
How Artsy Automates Team Culture
ashfurrow
0
3.5k
Building Custom TSLint Rules
ashfurrow
0
550
Circumventing Fear of the Unknown
ashfurrow
1
630
Building Better Software by Building Better Teams
ashfurrow
1
740
Building Open Source Communities
ashfurrow
0
1.1k
Building Compassionate Software
ashfurrow
0
630
Swift, Briskly
ashfurrow
0
220
Other Decks in Programming
See All in Programming
flutter_test のその先へ — Flutter アプリの LLM 機能に「評価」という品質保証を
kosukesaigusa
0
200
Secure Your Coding Agent Like It’s Malware (v1.5) 🇬🇧 @Code.talks 2026
richargh
0
110
Claude Code ハーネスDeep Dive – 君はどこまで制御する? -
takateeen_knj
6
4.7k
Event is what happens
moro
2
4k
TS 7.0 で baseUrl が使えなくなった今、パスエイリアスをどうするか
bicstone
2
580
Snowflake Openflow Connector利用の勘所 / 20261024developersio2026tokyo-snowflake-openflow
kasacchiful
PRO
0
320
Coding with AI: How to trust the storyteller (AWS Community Day Adria, Ljubljana 2026)
slobodan
0
140
Lambda durable functionsでHuman in the Loopを楽に…楽に……
har1101
2
300
React Native経験者が Flutterを30⽇間触って驚いたこと
3saito
0
170
Modernizing iOS Apps
seyfoyun
0
150
AmebaブログはKMPから卒業します
kmars0605
0
340
LLM 101: Exploring LLMs, Starting with Tokens.
dalinaum
0
100
Featured
See All Featured
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
600
We Have a Design System, Now What?
morganepeng
55
8.4k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
290
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
670
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.3k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
232
55k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3.1k
Done Done
chrislema
187
17k
The World Runs on Bad Software
bkeepers
PRO
72
12k
The Pragmatic Product Professional
lauravandoore
37
7.5k
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