Fireship · @fireship
Swift in 100 Seconds
Uploaded November 22, 2021 · Length 2:25
Summary
swift language basics and features in 100 seconds, including syntax, memory safety, and object-oriented programming.
- swift programming language
- swift basics
- swift syntax
- swift memory safety
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
swift a multi-paradigm compiled language
- 0:02
created by apple famous for building
- 0:04
apps that grow inside of apple's walled
- 0:06
garden it was first introduced in 2014
- 0:09
at the worldwide developers conference
- 0:10
and was designed as a modern successor
- 0:12
to objective-c the original apple
- 0:14
platform language that had been in use
- 0:16
since the 1980s swift interops with
- 0:18
objective-c but provides a shorter more
- 0:20
readable syntax and features like memory
- 0:23
safety and type inference to improve
- 0:25
developer productivity today it's used
- 0:27
to build mobile apps on ios desktop apps
- 0:29
on mac os wearable apps for watch os but
- 0:32
is also open source which means it can
- 0:34
be used to build software outside of
- 0:36
apple platforms it compiles to native
- 0:38
machine code and is built on top of the
- 0:40
llvm tool chain like many other modern
- 0:42
languages however it also supports a
- 0:44
readable print loop allowing you to
- 0:46
experiment with code in a playground
- 0:47
without needing to recompile making it a
- 0:50
great language for beginners in addition
- 0:52
it provides memory safety by preventing
- 0:54
you from writing unsafe code by default
- 0:56
and uses automatic reference counting to
- 0:58
manage memory automatically to get
- 1:00
started install it then create a file
- 1:02
ending in.swift your code will start
- 1:04
executing in the global scope there's no
- 1:06
need for a main function create a
- 1:08
variable with the var keyword followed
- 1:10
by its name and value var creates a
- 1:12
mutable variable which means its value
- 1:14
can change in the future let on the
- 1:16
other hand creates an immutable variable
- 1:18
or constant it uses type inference to
- 1:21
strongly type the value as a string but
- 1:23
we can explicitly type it by adding a
- 1:25
semicolon after the variable name every
- 1:27
variable must be initialized with a
- 1:29
value unless the type has a question
- 1:31
mark which makes it an optional type
- 1:32
allowing it to also contain a nil value
- 1:35
it also supports optional chaining
- 1:37
making it really easy to work with nil
- 1:38
values functions are declared with the
- 1:40
fun keyword and will use named
- 1:42
parameters by default place an
- 1:43
underscore before the name to use
- 1:45
positional arguments instead now use a
- 1:47
backslash with parentheses to
- 1:49
interpolate these values into a string
- 1:51
functions in swift are first class
- 1:52
objects they can be passed as arguments
- 1:54
used as return values and nested to
- 1:56
create closures it also supports
- 1:58
object-oriented patterns like classes


