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
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
350
Go の GC の不得意な部分を克服したい
taiyow
3
840
歴史と現在から考えるスケーラブルなソフトウェア開発のプラクティス
i10416
0
140
【re:Growth 2024】 Aurora DSQL をちゃんと話します!
maroon1st
0
810
PHPで学ぶプログラミングの教訓 / Lessons in Programming Learned through PHP
nrslib
4
400
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
4
360
これが俺の”自分戦略” プロセスを楽しんでいこう! - Developers CAREER Boost 2024
niftycorp
PRO
0
200
どうして手を動かすよりもチーム内のコードレビューを優先するべきなのか
okashoi
3
590
責務を分離するための例外設計 - PHPカンファレンス 2024
kajitack
8
1.9k
fs2-io を試してたらバグを見つけて直した話
chencmd
0
240
CQRS+ES の力を使って効果を感じる / Feel the effects of using the power of CQRS+ES
seike460
PRO
0
160
暇に任せてProxmoxコンソール 作ってみました
karugamo
2
730
Featured
See All Featured
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
1
110
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
28
2.1k
Facilitating Awesome Meetings
lara
50
6.1k
Stop Working from a Prison Cell
hatefulcrawdad
267
20k
Designing for humans not robots
tammielis
250
25k
A Tale of Four Properties
chriscoyier
157
23k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
Thoughts on Productivity
jonyablonski
68
4.4k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
RailsConf 2023
tenderlove
29
940
Done Done
chrislema
182
16k
4 Signs Your Business is Dying
shpigford
182
21k
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!