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
650
ざっくりわかる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
160
1人で挑むSwiftコンパイラ 〜型システム入門編〜
s_shimotori
0
520
英語
s_shimotori
1
470
Parallel Socket Communication in Swift
s_shimotori
1
650
UIColor Anatomy
s_shimotori
1
2.3k
UIColor Cluster
s_shimotori
1
690
iOSDC Japan 2019 60 mins for color
s_shimotori
5
3.7k
wwdc19
s_shimotori
2
330
SE-0246 Generic Math(s) Functions
s_shimotori
2
2.4k
Other Decks in Programming
See All in Programming
Ethereum_.pdf
nekomatu
0
460
WebフロントエンドにおけるGraphQL(あるいはバックエンドのAPI)との向き合い方 / #241106_plk_frontend
izumin5210
4
1.4k
.NET のための通信フレームワーク MagicOnion 入門 / Introduction to MagicOnion
mayuki
1
1.5k
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
1
290
TypeScriptでライブラリとの依存を限定的にする方法
tutinoko
2
660
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
110
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
2
120
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
520
Quine, Polyglot, 良いコード
qnighy
4
640
watsonx.ai Dojo #4 生成AIを使ったアプリ開発、応用編
oniak3ibm
PRO
1
100
見せてあげますよ、「本物のLaravel批判」ってやつを。
77web
7
7.7k
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
220
Featured
See All Featured
Git: the NoSQL Database
bkeepers
PRO
427
64k
Visualization
eitanlees
145
15k
Automating Front-end Workflow
addyosmani
1366
200k
Building Better People: How to give real-time feedback that sticks.
wjessup
364
19k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
126
18k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
The Language of Interfaces
destraynor
154
24k
A Philosophy of Restraint
colly
203
16k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
229
52k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
Agile that works and the tools we love
rasmusluckow
327
21k
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͍͚ΔΜͩΜͳʔͣΔ͍Αͳʔ