Fireship · @fireship
Rust in 100 Seconds
Uploaded October 12, 2021 · Length 2:29
Summary
rust programming language basics, memory safety, and performance optimization in 100 seconds
- rust programming language
- memory safety
- performance optimization
- ownership and borrowing
- cargo package manager
Transcript preview
The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.
- 0:00
rust a memory safe compiled programming
- 0:02
language that delivers highlevel
- 0:04
Simplicity with low-level performance
- 0:06
it's a popular choice for Building
- 0:07
Systems where performance is absolutely
- 0:09
critical like game engines databases or
- 0:12
operating systems and is an excellent
- 0:14
choice when targeting web assembly it
- 0:16
started as a side project of gr on
- 0:18
in 2007 who named it after the rust
- 0:21
fungus it was sponsored by Mozilla in
- 0:23
2009 and has been ranked the most Lov
- 0:25
programming language every year since
- 0:27
2016 with its fans being known as
- 0:29
restation traditionally highle languages
- 0:32
provide a garbage collector to Nerf your
- 0:34
control over memory management while
- 0:36
lower level languages provide functions
- 0:38
like free and allocate to shoot yourself
- 0:40
in the foot rust takes a different
- 0:42
approach it has no garbage collector but
- 0:44
achieves memory safety with a concept
- 0:46
known as ownership and borrowing by
- 0:48
default every variable in Rust is
- 0:50
immutable this allows values to be used
- 0:52
in the stack memory which has minimal
- 0:53
performance overhead however mutable
- 0:55
values or objects with an unknown size
- 0:58
at compile time are stored in the keep
- 1:00
memory every value in a rust program is
- 1:02
assigned to a single variable known as
- 1:04
its owner when that variable goes out of
- 1:06
scope the memory allocated to it is
- 1:08
dropped automatically in some cases
- 1:10
though you may want to pass a reference
- 1:12
to a different part of the program
- 1:13
borrowing allows you to access a
- 1:15
reference in memory without taking
- 1:17
ownership of it there are a ton of rules
- 1:19
to go along with the system that the r
- 1:21
borrow Checker will validate at compile
- 1:23
time these rules keep your code safe
- 1:25
while providing absolute control over
- 1:27
performance rust also has a package
- 1:29
manager called cargo where each
- 1:30
individual package is a crate to get
- 1:33
started install rest then run cargo new
- 1:35
from the command line in the main. RS
- 1:37
file you'll find a main function which
- 1:39
is where the program will start
- 1:41
executing declare a variable with let
- 1:43
followed by its name and type the value
- 1:45
can't be changed or reassigned by
- 1:47
default so add mut to make it mutable
- 1:49
the name of the variable is the owner a
- 1:51
reference to its location and memory can
- 1:53
be Borrowed by other parts of the
- 1:54
program by prefixing it with an Amper
- 1:56
sand then use a macro like print line to
- 1:59
log the value to the standard output


