-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathpresentation.txt
408 lines (254 loc) · 6.25 KB
/
presentation.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
How Swift Works
Under the Hood
By:
Aaron Krauss
\@thecodeboss
@images/clevyr.png
OKC WebDevs
@images/meetup.png
How Swift Works
Under the Hood
The Plan
* What It Is
* History
* Programming Concepts
* Storyboard / SwiftUI
* The Future
* Demo
There will be minimal code in this talk
So why have this talk?
What It Is
Swift is a powerful and intuitive
programming language for iOS,
iPadOS, macOS, tvOS, and watchOS
Swift is a general-purpose, multi-paradigm language
* Object-Oriented
* Protocol-Oriented
* Declarative (w/ Swift UI)
Gone are the days of saying
something is just OO
Swift is open-source
Built as a replacement for
Objective-C
Notable Architecture Decisions:
* No semicolons
* Type inference
* Strings are UTF-8
* Memory managed by Reference Counting
* Functions are First Class Citizens
* Optional types
* Interop w/ Objective C
My personal favorite: guard
@images/swift-guard.png
Supports Apple Cocoa and
Cocoa Touch Frameworks
Cocoa and Cocoa Touch are
the run-time application environments
for OSX and iOS
@images/swift-cocoa.png
History
First release in June 2, 2014
by Apple
Announced at 2014 Apple WWDC
Swift v2 announced at 2015 Apple WWDC
Became Open-Source in
December 3, 2015
Officially became more popular
than Objective-C in Q1 2018
Programming Concepts
* Compiled vs. Interpreted
* Static vs. Dynamic Type Checking
* Type Safety
* Concurrency
* Garbage Collection
* Functional Programming
* Imperative vs. Declarative
Compiled vs. Interpreted
Swift is compiled
Now when we say
compiled / interpreted
We're referring to an implementation
of the language
Not the language itself
Compiled
Pros
* Speed / Performance
* Typically build with static type-checking
Cons
* Usually not cross-platform
* Must compile everytime
* Don't usually have benefits of
dynamic type-checking
Interpreted
* Usually cross platform
* No compilation step
* Typically built with dynamic type-checking
Cons
* Less speed / performance
* Don't usually have benefits of
static type-checking
Bonus: Bytecode
* Some of compiled performance
* Usually cross-platform
* Can use same VM as other bytecode languages
JVM
Convert your language into JVM bytecode,
run it on the JVM
Static vs. Dynamic
Type Checking
Swift is a statically
typed-checked language
Unlike compiled/interpreted,
type checking is a language feature
Static type checking
* Track type errors early
at compile time
* Makes runtime modifications more challenging
* Static type checking is more rigid
on your development style
Dynamic type checking
* Easier to implement
reflection, metaprogramming, etc.
* Also easier to introduce type-related
bugs into your code
Dynamically type-checked languages
often encourage testing with your code
Type Safety
Strong vs. Weak Typing
Swift is a strongly typed language
Strong / Weak Typing means
"how" type safety is enforced
x = 1
y = "2"
x + y = ?
It has nothing to do with syntax
Examples of strongly typed language:
* Java
* Python
* Javascript
Examples of weakly typed language
* PHP
* C
static vs dynamic type checking
means "when" type safety is enforced
Strong / Weak Typing means
"how" type safety is enforced
Concurrency
Swift supports concurrency
Concurrency != Parallelism
Swift 5.5 (2021) expands concurrency support
via the "actor" model
Swift does not appear to support
true parallelism
Garbage Collection
2 main algorithms
1. Reference Counting
2. Mark - Sweep
Stop-the-world, concurrent, generational
Swift uses Automatic Reference Counting
Problem of circular dependencies
A -> B
B -> A
Swift mitigates this with "weak"
and "unowned" keywords
Functional Programming Concepts
Swift is not considered a FP language
But it applies many of the concepts
Functions as first class citizens
Map / Filter functions
What FP concepts does it not include?
* Pure functions
* Referential transparency
* Immutable variables
Imperative vs. Declarative
Imperative
Where you tell your code what to do
Swift Storyboard is imperative
Declarative
Where you describe what you want
E.g. SQL
Swift UI is declarative
Learn more programming concepts at
https://thecodeboss.dev/blog/
Storyboard / SwiftUI
Storyboard & XIB
.xib and .storyboard files
are user interface files
.xib = one view controller / menu bar
.storyboard = many
@images/swift-storyboard.png
Very much a drag-and-drop
GUI-driven style of working
Storyboard is an imperative
style of development
Problems
Interface Builder was released in
1988
Most recent stable releases (3.2.6 & 4)
were released in March 2011, after which
it became a part of Xcode 4
Behind the scenes, Storyboards / XIB
generate a lot of XML
You really need the Interface Builder
to do anything
That, and your UI and your code are
often separated
Swift UI
During WWDC 2019, Apple announced
SwiftUI with Xcode 11
Swift UI is declarative
@images/swift-swiftui-code.png
More power to the developer,
with less extra fluff to worry about
Problems
* Community
* No Objective-C support (only in SwiftUI files)
Goals:
* Simplify your dev process
* Unify the experience
* Expand your platform support
@images/swift-swiftui-design.png
The Future
Cross platform
Will Swift ever be Android's
main language too?
It's hard to say
In 2017, there were rumors that
Google would full-blown support Swift
Also in 2017, Google announced
Android support for Kotlin
In 2019, Google stated Kotlin was the
preferred language for Android
So, it's not looking like Swift
will be the official Android
language any time soon
But, Swift seems to be headed in another direction
Supports Apple Platforms
Also supports Linux (2018) and Windows (2020)
for non-GUI server development
https://swift.org/getting-started
In October 2018, Apple announced work on
Language Server Protocol support for Swift.
A month later, a second post
introduced SourceKit-LSP.
So what's LSP?
The Language Server Protocol (LSP) is a
protocol created by Microsoft.
It allows for standardized communication between
a language and an editor or tool so that
editors can support all languages with LSP at once
@images/lsp.png
Getting back to "The Future"
Currently, cross-platform
support isn't all the way there
* LSP support
* Community
* Ease of use/installation
I think this will all change
Demo
thanks
* Aaron Krauss
* thecodeboss.dev
clevyr
clevyr.com
questions?