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
The ownership in iOS
Search
Yuji Taniguchi
April 20, 2018
Programming
0
340
The ownership in iOS
Yuji Taniguchi
April 20, 2018
Tweet
Share
More Decks by Yuji Taniguchi
See All by Yuji Taniguchi
Zeroconf on iOS
natpenguin
2
1.2k
Zero Configuration
natpenguin
1
170
Other Decks in Programming
See All in Programming
みんなでプロポーザルを書いてみた
yuriko1211
0
270
Jakarta EE meets AI
ivargrimstad
0
110
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
480
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
220
2024/11/8 関西Kaggler会 2024 #3 / Kaggle Kernel で Gemma 2 × vLLM を動かす。
kohecchi
5
930
RubyLSPのマルチバイト文字対応
notfounds
0
120
CSC509 Lecture 09
javiergs
PRO
0
140
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
1
300
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
1.7k
EMになってからチームの成果を最大化するために取り組んだこと/ Maximize team performance as EM
nashiusagi
0
100
距離関数を極める! / SESSIONS 2024
gam0022
0
280
as(型アサーション)を書く前にできること
marokanatani
10
2.7k
Featured
See All Featured
The Pragmatic Product Professional
lauravandoore
31
6.3k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
Become a Pro
speakerdeck
PRO
25
5k
Optimizing for Happiness
mojombo
376
70k
Building Adaptive Systems
keathley
38
2.3k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
44
2.2k
Unsuck your backbone
ammeep
668
57k
Site-Speed That Sticks
csswizardry
0
27
Happy Clients
brianwarren
98
6.7k
Transcript
The ownership in iOS Mixleap #11 in Osaka
@_natpenguin merpay iOS Software Engineer
@_natpenguin merpay iOS Software Engineer .filter { $0 == }
.map { $0 + } + [ , ✨ ] =
What is ownership?
It’s a management system for resource
It’s abstract word…
Ownership system is already used
Rust/C++/Swift… Ownership system is already used
Why we need ownership system?
None
- Speed
- Safety - Speed
- Safety - Speed - Concurrency
Safety
- Access conflict to Data Rust prevents these in compiling
- Access conflict to Data Rust prevents these in compiling
- Using after releasing resource
fn main() { let x = vec![1, 2, 3]; let
y = x; println!(“x[0] is {}", x[0]); } This code will be compiling error
fn main() { let x = vec![1, 2, 3]; take(x);
println!(“x[0] is {}", x[0]); } fn take(v: Vec<i32>) { // do something } This code will be compiling error
fn main() { let mut x = &100; let mut
y = &mut x; *y += 1; println!(“y is {}", y); } This code will be compiling error
It’s a difficult
None
Manifesto https://github.com/apple/swift/blob/master/docs/OwnershipManifesto.md
Q. What does swift want by using it?
A. Improving performance Q. What does swift want by using
it?
- Making extra copies at runtime Problem Point
- Making extra copies at runtime - Referencing to unique
resource Problem Point
- Making extra copies at runtime - Referencing to unique
resource - Overhead of reference count Problem Point
Point - Prevents simultaneously accessing to Data
Point - Prevents simultaneously accessing to Data - Give programmers
more control
Point - Prevents simultaneously accessing to Data - Give programmers
more control - Add types that can’t be implicitly copied
A1. Supporting a type that can’t copy Q. How does
swift improve performance?
A1. Supporting a type that can’t copy Q. How does
swift improve performance? A2. Law of exclusivity
New keywords - shared
func ==(left: shared String, right: shared String) -> Bool {
... } shared String isn’t copied
What is different with inout?
- shared - inout
New keywords - shared - moveonly
moveonly struct Foo { // some parameters }
moveonly extension Foo { // Some extensions }
extension Foo { moveonly func bar<U>(_ u: U) }
moveonly struct File { let descriptor: Int32 init(filename: String) throws
{ descriptor = Darwin.open(filename, O_RDONLY) } deinit { _ = Darwin.close(descriptor) } }
When we use it? - Performance tuning
When we use it? - More memory management - Performance
tuning
When we use it? - More memory management - Performance
tuning - Already know that no needed to copy
Thank you so much!