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
Comparative Asynchronous Programming
Search
Ash Furrow
February 24, 2017
Programming
2
9.7k
Comparative Asynchronous Programming
Presented at Playgrounds Conf:
http://www.playgroundscon.com/
Ash Furrow
February 24, 2017
Tweet
Share
More Decks by Ash Furrow
See All by Ash Furrow
Migrating to React Native: A Long-Term Retrospective
ashfurrow
0
280
How Artsy Automates Team Culture
ashfurrow
0
3.3k
Building Custom TSLint Rules
ashfurrow
0
460
Circumventing Fear of the Unknown
ashfurrow
1
560
Building Better Software by Building Better Teams
ashfurrow
1
620
Building Open Source Communities
ashfurrow
0
920
Building Compassionate Software
ashfurrow
0
500
Swift, Briskly
ashfurrow
0
170
iOS Checkup
ashfurrow
1
890
Other Decks in Programming
See All in Programming
コードレビューをしない選択 #でぃーぷらすトウキョウ
kajitack
3
1k
20260228_JAWS_Beginner_Kansai
takuyay0ne
5
580
エンジニアの「手元の自動化」を加速するn8n 2026.02.27
symy2co
0
160
Codexに役割を持たせる 他のAIエージェントと組み合わせる実務Tips
o8n
4
1.4k
Docコメントで始める簡単ガードレール
keisukeikeda
1
120
Go Conference mini in Sendai 2026 : Goに新機能を提案し実装されるまでのフロー徹底解説
yamatoya
0
610
Agent Skills Workshop - AIへの頼み方を仕組み化する
gotalab555
15
8.9k
Windows on Ryzen and I
seosoft
0
320
[SF Ruby Feb'26] The Silicon Heel
palkan
0
110
go directiveを最新にしすぎないで欲しい話──あるいは、Go 1.26からgo mod initで作られるgo directiveの値が変わる話 / Go 1.26 リリースパーティ
arthur1
2
560
Fundamentals of Software Engineering In the Age of AI
therealdanvega
2
260
Claude Codeセッション現状確認 2026福岡 / fukuoka-aicoding-00-beacon
monochromegane
4
430
Featured
See All Featured
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.8k
Paper Plane (Part 1)
katiecoart
PRO
0
5.7k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.3k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.1k
Ethics towards AI in product and experience design
skipperchong
2
230
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
320
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
118
110k
Utilizing Notion as your number one productivity tool
mfonobong
4
260
Designing for Performance
lara
611
70k
Evolving SEO for Evolving Search Engines
ryanjones
0
160
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