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
540
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
From Translations to Multi Dimension Entities
alexanderschranz
2
130
Go の GC の不得意な部分を克服したい
taiyow
2
770
Haze - Real time background blurring
chrisbanes
1
510
17年周年のWebアプリケーションにTanStack Queryを導入する / Implementing TanStack Query in a 17th Anniversary Web Application
saitolume
0
250
Refactor your code - refactor yourself
xosofox
1
260
Cloudflare MCP ServerでClaude Desktop からWeb APIを構築
kutakutat
1
540
tidymodelsによるtidyな生存時間解析 / Japan.R2024
dropout009
1
770
CSC305 Lecture 25
javiergs
PRO
0
130
短期間での新規プロダクト開発における「コスパの良い」Goのテスト戦略」 / kamakura.go
n3xem
2
170
Асинхронность неизбежна: как мы проектировали сервис уведомлений
lamodatech
0
710
快速入門可觀測性
blueswen
0
340
The Efficiency Paradox and How to Save Yourself and the World
hollycummins
1
440
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
132
33k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
48
2.2k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
28
900
How to Ace a Technical Interview
jacobian
276
23k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7k
The Cost Of JavaScript in 2023
addyosmani
45
7k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
Become a Pro
speakerdeck
PRO
26
5k
GitHub's CSS Performance
jonrohan
1030
460k
Documentation Writing (for coders)
carmenintech
66
4.5k
Navigating Team Friction
lara
183
15k
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͍͚ΔΜͩΜͳʔͣΔ͍Αͳʔ