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
630
ざっくりわかるSwift
https://connpass.com/event/60103/
#TokyoTechLT
Shigure Shimotori
July 19, 2017
Tweet
Share
More Decks by Shigure Shimotori
See All by Shigure Shimotori
1人で挑むSwiftコンパイラ 〜型システム入門編〜
s_shimotori
0
320
英語
s_shimotori
1
330
Parallel Socket Communication in Swift
s_shimotori
1
590
UIColor Anatomy
s_shimotori
1
2.2k
UIColor Cluster
s_shimotori
1
640
iOSDC Japan 2019 60 mins for color
s_shimotori
5
3.6k
wwdc19
s_shimotori
2
320
SE-0246 Generic Math(s) Functions
s_shimotori
2
2.4k
Introduction to Font and Typesetting
s_shimotori
4
3.7k
Other Decks in Programming
See All in Programming
Why Prism?
kddnewton
4
1.4k
初めてのiOS関連GitHub ActionsをMarketplaceに公開するまでの実録
konifar
3
200
Rechartsで楽にゴリゴリにカスタマイズする!
10tera
1
140
私の考える初学者がBlazorできるまでの学習方法
tomokusaba
1
250
複雑さに立ち向かうための ソフトウェア開発入門
shiz
3
650
ECMAScript仕様を読むのに必要な知識 - ダイジェスト版
syumai
4
2.6k
LR で JSON パーサーを作る / Coding LR JSON Parser
junk0612
2
180
Go Code Generation at newmo / 2024-08-27 #newmo_layerx_go
genkey6
0
540
Ebitengineの1vs1ゲーム WebRTCの活用
ponyo877
0
350
Ruby Parser progress report 2024
yui_knk
2
190
全部見せます! クラシルリワードのSwiftTesting移行プロジェクト
uetyo
0
150
労務ドメインを快適に開発する方法 / How to Comfortably Develop in the Labor Domain
yuki21
1
250
Featured
See All Featured
Design by the Numbers
sachag
277
19k
Pencils Down: Stop Designing & Start Developing
hursman
118
11k
What’s in a name? Adding method to the madness
productmarketing
PRO
21
3k
Clear Off the Table
cherdarchuk
90
320k
Art, The Web, and Tiny UX
lynnandtonic
294
20k
How to train your dragon (web standard)
notwaldorf
85
5.6k
What the flash - Photography Introduction
edds
67
11k
The Cult of Friendly URLs
andyhume
76
5.9k
The Pragmatic Product Professional
lauravandoore
30
6.2k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Happy Clients
brianwarren
96
6.6k
The Invisible Customer
myddelton
119
13k
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͍͚ΔΜͩΜͳʔͣΔ͍Αͳʔ