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
ざっくりわかるSwift
Search
Shigure Shimotori
July 19, 2017
Programming
0
660
ざっくりわかるSwift
https://connpass.com/event/60103/
#TokyoTechLT
Shigure Shimotori
July 19, 2017
Tweet
Share
More Decks by Shigure Shimotori
See All by Shigure Shimotori
Synchronizationを支える技術
s_shimotori
1
180
1人で挑むSwiftコンパイラ 〜型システム入門編〜
s_shimotori
0
620
英語
s_shimotori
1
550
Parallel Socket Communication in Swift
s_shimotori
1
680
UIColor Anatomy
s_shimotori
1
2.4k
UIColor Cluster
s_shimotori
1
700
iOSDC Japan 2019 60 mins for color
s_shimotori
5
3.7k
wwdc19
s_shimotori
2
340
SE-0246 Generic Math(s) Functions
s_shimotori
2
2.4k
Other Decks in Programming
See All in Programming
フロントエンドのディレクトリ構成どうしてる? Feature-Sliced Design 導入体験談
osakatechlab
8
4.1k
数十万行のプロジェクトを Scala 2から3に完全移行した
xuwei_k
0
280
各クラウドサービスにおける.NETの対応と見解
ymd65536
0
110
LLM Supervised Fine-tuningの理論と実践
datanalyticslabo
7
1.3k
Jakarta EE meets AI
ivargrimstad
0
250
Amazon S3 NYJavaSIG 2024-12-12
sullis
0
100
コンテナをたくさん詰め込んだシステムとランタイムの変化
makihiro
1
130
Effective Signals in Angular 19+: Rules and Helpers @ngbe2024
manfredsteyer
PRO
0
140
Mermaid x AST x 生成AI = コードとドキュメントの完全同期への道
shibuyamizuho
0
160
Beyond ORM
77web
7
900
RWC 2024 DICOM & ISO/IEC 2022
m_seki
0
210
rails stats で紐解く ANDPAD のイマを支える技術たち
andpad
1
290
Featured
See All Featured
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.3k
A Tale of Four Properties
chriscoyier
157
23k
Building Better People: How to give real-time feedback that sticks.
wjessup
365
19k
How To Stay Up To Date on Web Technology
chriscoyier
789
250k
BBQ
matthewcrist
85
9.4k
Code Review Best Practice
trishagee
65
17k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Typedesign – Prime Four
hannesfritz
40
2.4k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.3k
Producing Creativity
orderedlist
PRO
341
39k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
45
2.2k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
10
810
Transcript
ͬ͘͟ΓΘ͔ΔSwift TokyoTech LT #2 @S_Shimotori
୭ʁ • @S_Shimotori (@S_Shimotori_pub) • ऑΤֶܥM2 • DroidKaigiӡӦελοϑ • SwiftPythonΛॻ͍͓ͯۚΛ͏͓ࣄ
DroidKaigi2018 ։࠵ܾఆʂ 20182݄8-9@ϕϧαʔϧ৽॓άϥϯυ https://droidkaigi.github.io/2018/
AndroidͱiOSͷڥͷҧ͍ • Android • ॳճ͚ͩొྉΛ͑OK • ຊAndroidͷձ͕͋Δɺֶੜ෦͋Δ • ࠓKotlin͕͍ʂ •
iOS • ຖ͓ࢪ͕ඞཁ • ͦΜͳձ͚͋ͬͨͬ • ·ͨSwift4ʹॻ͖͑Δ࡞ۀ͕͡·Δ͓…
ϞόΠϧͷҎ্ʂ
ຊ
͓ॻ͖ • Swiftͷจ๏ͷ֓ཁ • Swift͕͑Δॴ • CϥΠϒϥϦͷݺͼग़͠ • Swiftʹ͍ͭͯͬͱΓ͍ͨͱ͖
͓ॻ͖ • Swiftͷจ๏ͷ֓ཁ • Swift͕͑Δॴ • CϥΠϒϥϦͷݺͼग़͠ • Swiftʹ͍ͭͯͬͱΓ͍ͨͱ͖
Swiftͷจ๏ͷ֓ཁ
ཁ͢Δͱ͜Μͳ͔Μ͡ʂ • ϓϩτίϧࢦ / ΦϒδΣΫτࢦ / ؔܕ / ໋ྩܕ /
ϒϩοΫߏ • ڧ͍੩తܕ͚ / ܕਪ • Objective-C͔ΒͷӨڹ͋Γ • Swift4Ӷҙ࡞த • ܕ҆શnull҆શɻૉΒ͍͠ɻ • LLVMͱ͔ͳΜͱ͔ https://en.wikipedia.org/wiki/Swift_(programming_language)
ϓϩτίϧࢦʁ
Swiftyʹॻ্͘ͰѲ͓͖͍ͯͨ͜͠ͱ • SwiftʹclassͷଞʹstructɺenumɺprotocolΛ࣋ͭ • protocol”ಛఆͷॲཧͷͨΊͷϝιουͷઃܭਤ” • JavaͰ͍͏ͱ͜Ζͷinterface • ͭ·ΓΘͳͯ͘ಈ͔ͳ͍͜ͱͳ͍ •
Swift3ඪ४ϥΠϒϥϦͷ201γϯϘϧͷ͏ͪɺ struct140ݸɺenum12ݸɺprotocol48ݸɺ classͳΜͱ1ݸʂ
Java Comparable<T>ͱSwift Comparable • Java Comparable<T> • Swift Comparable μΠϚ
http://qiita.com/S_Shimotori/items/83e22d83f5c0096a6d5b http://hg.openjdk.java.net/jdk8/jdk8/jdk/file/687fd7c7986d/src/share/classes/java/lang/Comparable.java https://github.com/apple/swift/blob/c15c671372620b543e19a662218a247f601628e4/stdlib/public/core/Comparable.swift ※ ࣮ࡍEquatableͷ “=” ͱComparableͷ ”<“ Λ࣮͢ΕΓΔ
OptionalͱCommandLine • Optionalenum Optional<Wrapped> • .some(Wrapped)ͱ.noneΛྻڍ • Nullableͷਖ਼ମ • enum
CommandLineྻڍͯ͠ͳ͍ • ྻڍܕ͕ࣗΠχγϟϥΠζ͞Εͳ͍ಛੑΛར༻ https://github.com/apple/swift/blob/master/stdlib/public/core/CommandLine.swift https://github.com/apple/swift/blob/master/stdlib/public/core/Optional.swift Optional<String>ͷҥߏจ
ͪͳΈʹ: ԋࢉࢠΛఆٛ͢Δ • SwiftࣗͰԋࢉࢠΛఆٛ͢Δ͜ͱ͕Մೳ • ओʹؔܕ͍ͨ͠ਓ͕࡞Δ “>=“ • ͑Δه߸ແͦ͏ͳͭ •
/ = - + ! * % < > & | ^ ~ ?ͱ͔ଞ͍Ζ͍Ζ • ͑ʁ$͕ͩΊͳͷʹὺ͕͑Δͷʁʁ
ܕਪ͋ΔΜͩͶ͐ ͍͍ͪͪܕΛॻ͔ͳ͍͍ͯ͘Ͷʂ
SwiftͰܕਪͱ͍ͬͨΒ…… • ʮίϯύΠϧ࣌ؒͷେ͕ܕਪ͡ΌΜwʯ • ʮਪʹ͔͔͔࣌ؒͬͨΒίϯύΠϧఘΊ·ͨ͠Τϥʔʯ • ղܾࡦ: • ৽͍͠όʔδϣϯͷSwift(ͱXcode9)Λ͏ •
એݴ࣌ʹͪΌΜͱܕΛॻ͘ • ؔܕͳΜͯͳ͔ͬͨɻ͍͍Ͷʁ
ΤϥʔදݱͲ͏ͳͬͯΜͷʁ
Swiftʹ͓͚ΔΤϥʔදݱ • جຊతʹNonNullɺthrowͳ͠ • ޭ/ࣦഊͷ2ΓNullableͰදݱ • Optional.some(Wrapped)ͰแΜͰฦ͢ • Լॲཧ͠ͳ͍ͱแΜͩத͑ͳ͍ʂ •
ΑΓৄࡉͳΤϥʔදݱΛ͢ΔͳΒErrorΛ͛Δ • Τϥʔ͕ى͖ͳ͍͜ͱ͕໌Β͔ͳΒ”!”Ͱ௵͢
͓ॻ͖ • Swiftͷจ๏ͷ֓ཁ • Swift͕͑Δॴ • CϥΠϒϥϦͷݺͼग़͠ • Swiftʹ͍ͭͯͬͱΓ͍ͨͱ͖
Swift͕͑Δॴ
͋ʔ͍͍iOSͶ ڵຯͳ͍ΜͰ✋
DarwinҎ֎Ͱ͑Δ͔Βʂ ͕͢͞ʹ2.2ݹ͍͕
LinuxͰSwift • swift.orgͷUbuntu༻όΠφϦ͔dockerΛ͏ͷָ͕ • Կ͔࡞Δ࣌Swift Package ManagerΛ͏ͱྑ͍ • ґଘؔղܾͨ͠Γςετͨ͠Γ͢Δ •
ίϚϯυϥΠϯπʔϧ͕࡞ΕΔ • WebϑϨʔϜϫʔΫͰWebΞϓϦ͕࡞ΕΔ • Perfectͱ͔Vaporͱ͔ͦͷΜ
ͱ͜ΖͰ
Swift͕Ͱ͖Δ͜ͱɺ୯ͰͰ͖ͳ͍͜ͱ • Swiftଂͷඪ४ϥΠϒϥϦ͕Ͱ͖Δ͜ͱ • هड़ʹඞཁͳػೳͷجຊ • Stringͱ͔printͱ͔ͦ͏͍͏ͷ • “import Foundation”ͰͰ͖Δ͜ͱ
• ΞϓϦͷجຊతͳػೳʹؔΘΔૢ࡞ • ϑΝΠϧͱ͔ηογϣϯͱ͔ͦ͏͍͏ͷ • Darwin༻FoundationͱLinux༻Foundationผ (༁)
swift-corelibs-foundationਐḿঢ়گ(7݄17ݱࡏ) https://github.com/apple/swift-corelibs-foundation/blob/master/Docs/Status.md “Unimplemented”
͓ॻ͖ • Swiftͷจ๏ͷ֓ཁ • Swift͕͑Δॴ • CϥΠϒϥϦͷݺͼग़͠ • Swiftʹ͍ͭͯͬͱΓ͍ͨͱ͖
CϥΠϒϥϦͷݺͼग़͠ (SPMͰͷ) iOS/macOSͬͱ͔ΜͨΜɻ
SPMͰCϥΠϒϥϦΛ͏ • ޙൃݴޠΒ͘͠ͲΜͲΜઌഐͷҨ࢈Λ͍ͬͯ͘ • Foundation͕ΞϨͳͷͰ͍ݹ͞ΕͨϥΠϒϥϦͷ ํ͕҆৺ • SPMͰϥοϓ͠ɺ1ͭͷύοέʔδͱͯ͠ѻ͏ • ґଘϦετʹSwiftͷͷCͷͷҰॹʹฒͿ
• ໊લΛCHogeͱ͢Δ׳ྫ͕͋Δ • cURLͳΒCCurlͱ͔
͕ൃੜ͢ΔΓํ ΅͘ͷߟ͍͖͑ͨ͞ΐ͏ͷ41.ύοέʔδ ύοέʔδ" ύοέʔδ# ύοέʔδ$ *#.4XJGU $$VSM 44IJNPUPSJ $$VSM D63-
·Ί͖ͪ͠: IBM͕ΜͬͯSwiftͯ͠Δɻ͍͍ͻͱɻ ໊લিಥ (ґଘݩˠґଘઌ)
͓ॻ͖ • Swiftͷจ๏ͷ֓ཁ • Swift͕͑Δॴ • CϥΠϒϥϦͷݺͼग़͠ • Swiftʹ͍ͭͯͬͱΓ͍ͨͱ͖
Swiftʹ͍ͭͯ ͬͱΓ͍ͨͱ͖
ͱΓ͋͑ͣॻ͖ͳ͕ΒͬͯΈ͍ͨʂ • ԦಓXcodeͰߦ͖͍ͨਓ • Xcode8ʹϦϑΝΫλϦϯάػೳ͕ͳ͍(স) • playgroundsͰؾܰʹॻ͚Δɺͨͷ͍͠ • JetBrainsڭͷਓ •
iOSͱҰॹʹΔͳΒAppCodeɺpure SwiftͳΒCLion • Vimmer • ͪΌΜͱߋ৽͕͍͍ͭͯΔͷͳ͍Μ͡Ό… • Emacser • ͪΌΜͱߋ৽͞ΕͯΔɺͣΔ͍
͋ͱ͜ͷลಡΜͰ͓͘ͱ͍͍Αɻ • https://developer.apple.com/library/content/documentation/Swift/ Conceptual/Swift_Programming_Language/ • https://developer.apple.com/documentation/swift • https://swift.org/
·ͱΊ
Swiftͷ͕͍͜͜͢͝ʂ • ڧ͍੩తܕ͚ͰprotocolͰenumͰ͍͢͝ʂ • αʔόίϚϯυϥΠϯπʔϧ࡞ΕΔʂ • ͦΕPythonͰΑ͘ͳ͍ʁ • ಈతܕ͚அͯ͡Noɺઈରʹڐ͞ͳ͍ •
ͦΕGo • ͦͷՄೳੑ͋Δ • ͦΕKotlin • ૉͰAWSLambda͍͚ΔΜͩΜͳʔͣΔ͍Αͳʔ