Skip to content

Commit 1162c55

Browse files
authored
Merge pull request #128 from google/speaker-notes
Add speaker notes for the first few slides
2 parents 49b4fff + f4b753b commit 1162c55

File tree

8 files changed

+150
-2
lines changed

8 files changed

+150
-2
lines changed

src/cargo/code-samples.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,18 @@ fn main() {
1818

1919
You can use <kbd>Ctrl-Enter</kbd> to execute the code when focus is in the text
2020
box.
21+
22+
<details>
23+
24+
Most code samples are editable like shown above. A few code samples
25+
are not editable for various reasons:
26+
27+
* The embedded playgrounds cannot execute unit tests. Copy-paste the
28+
code and open it in the real Playground to demonstrate unit tests.
29+
30+
* The embedded playgrounds lose their state the moment you navigate
31+
away from the page! This is the reason that the students should
32+
solve the exercises using a local Rust installation or via the
33+
Playground.
34+
35+
</details>

src/cargo/running-locally.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,11 @@ of the examples in this training:
6464
dependencies for you.
6565

6666
[1]: https://doc.rust-lang.org/book/ch01-01-installation.html
67+
68+
<details>
69+
70+
Try to encourage the class participants to install Cargo and use a
71+
local editor. It will make their life easier since they will have a
72+
normal development environment.
73+
74+
</details>

src/cargo/rust-ecosystem.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,32 @@ The Rust ecosystem consists of a number of tools, of which the main ones are:
1515
In addition, `rustup` can also download documentation for the standard
1616
library. You can have multiple versions of Rust installed at once and `rustup`
1717
will let you switch between them as needed.
18+
19+
<details>
20+
21+
Key points:
22+
23+
* Rust has a rapid release schedule with a new release coming out
24+
every six weeks. New releases maintain backwards compatibility with
25+
old releases --- plus they enable new functionality.
26+
27+
* There are three release channels: "stable", "beta", and "nightly".
28+
29+
* New features are being tested on "nightly", "beta" is what becomes
30+
"stable" every six weeks.
31+
32+
* Rust also has [editions]: the current edition is Rust 2021. Previous
33+
editions were Rust 2015 and Rust 2018.
34+
35+
* The editions are allowed to make backwards incompatible changes to
36+
the language.
37+
38+
* To prevent breaking code, editions are opt-in: you select the
39+
edition for your crate via the `Cargo.toml` file.
40+
41+
* To avoid splitting the ecosystem, Rust compilers can mix code
42+
written for different editions.
43+
44+
[editions]: https://doc.rust-lang.org/edition-guide/
45+
46+
</details>

src/welcome.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,11 @@ explain or contrast the Rust approach.
4242

4343
If you know how to program in a dynamically typed language such as Python or
4444
JavaScript, then you will be able to follow along just fine too.
45+
46+
<details>
47+
48+
This is an example of a _speaker note_. We will use these to add additional
49+
information to the slides. This could be key points which the instructor should
50+
cover as well as answers to typical questions which come up in class.
51+
52+
</details>

src/why-rust.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,20 @@ Some unique selling points of Rust:
55
* Compile time memory safety.
66
* Lack of undefined runtime behavior.
77
* Modern language features.
8+
9+
<details>
10+
11+
Make sure to ask the class which languages they have experience with. Depending
12+
on the answer you can highlight different features of Rust:
13+
14+
* Experience with C or C++: Rust eliminates a whole class of _runtime errors_
15+
via the borrow checker. You get performance like in C and C++, but you don't
16+
have the memory unsafety issues. In addition, you get a modern language with
17+
constructs like pattern matching and built-in dependency management.
18+
19+
* Experience with Java, Go, Python, JavaSript...: You get the same memory safety
20+
as in those languages, plus a similar high-level language feeling. In addition
21+
you get fast and predictable performance like C and C++ (no garbage collector)
22+
as well as access to low-level hardware (should you need it)
23+
24+
</details>

src/why-rust/compile-time.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,31 @@
33
Static memory management at compile time:
44

55
* No uninitialized variables.
6-
* *Mostly* no memory leaks[^leaks].
6+
* No memory leaks (_mostly_, see notes).
77
* No double-frees.
88
* No use-after-free.
99
* No `NULL` pointers.
1010
* No forgotten locked mutexes.
1111
* No data races between threads.
1212
* No iterator invalidation.
1313

14-
[^leaks]: It is technically possible to produce a memory leak in (safe) Rust. The [`Box::leak`](https://doc.rust-lang.org/std/boxed/struct.Box.html#method.leak) method allows getting a raw reference out of a [`Box`](https://doc.rust-lang.org/std/boxed/struct.Box.html) and dropping the [`Box`](https://doc.rust-lang.org/std/boxed/struct.Box.html) afterwards, without running the destructor. A use of this could be to get runtime-initialized and runtime-sized static variables. Or simply, the [`std::mem::forget`](https://doc.rust-lang.org/std/mem/fn.forget.html) function, which makes the compiler "forget" about a value meaning the destructor is never run. There are many other ways to create leaks in safe Rust, but for the purpose of this course, "No memory leaks" should be understood as "Pretty much no *accidental* memory leaks".
14+
<details>
15+
16+
It is possible to produce memory leaks in (safe) Rust. Some examples
17+
are:
18+
19+
* You can for use [`Box::leak`] to leak a pointer. A use of this could
20+
be to get runtime-initialized and runtime-sized static variables
21+
* You can use [`std::mem::forget`] to make the compiler "forget" about
22+
a value (meaning the destructor is never run).
23+
* You can also accidentally create a [reference cycle] with `Rc` or
24+
`Arc`.
25+
26+
For the purpose of this course, "No memory leaks" should be understood
27+
as "Pretty much no *accidental* memory leaks".
28+
29+
[`Box::leak`]: https://doc.rust-lang.org/std/boxed/struct.Box.html#method.leak
30+
[`std::mem::forget`]: https://doc.rust-lang.org/std/mem/fn.forget.html
31+
[reference cycle]: https://doc.rust-lang.org/book/ch15-06-reference-cycles.html
32+
33+
</details>

src/why-rust/modern.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,39 @@ Rust is built with all the experience gained in the last 40 years.
1313
* Great compiler errors.
1414
* Built-in dependency manager.
1515
* Built-in support for testing.
16+
17+
<details>
18+
19+
Key points:
20+
21+
* Remind people to read the errors --- many developers have gotten used to
22+
ignore lengthly compiler output. The Rust compiler is significantly more
23+
talkative than other compilers. It will often provide you with _actionable_
24+
feedback, ready to copy-paste into your code.
25+
26+
* The Rust standard library is small compared to languages like Java, Python,
27+
and Go. Rust does not come with several things you might consider standard and
28+
essential:
29+
30+
* a random number generator, but see [rand].
31+
* support for SSL or TLS, but see [rusttls].
32+
* support for JSON, but see [serde_json].
33+
34+
The reasoning behind this is that functionality in the standard library cannot
35+
go away, so it has to be very stable. For the examples above, the Rust
36+
community is still working on finding the best solution --- and perhaps there
37+
isn't a single "best solution" for some of these things.
38+
39+
Rust comes with a built-in package manager in the form of Cargo and this makes
40+
it trivial to download and compile third-party crates. A consequence of this
41+
is that the standard library can be smaller.
42+
43+
Discovering good third-party crates can be a problem. Sites like
44+
<https://lib.rs/> help with this by letting you compare health metrics for
45+
crates to find a good and trusted one.
46+
47+
[rand]: https://docs.rs/rand/
48+
[rusttls]: https://docs.rs/rustls/
49+
[serde_json]: https://docs.rs/serde_json/
50+
51+
</details>

src/why-rust/runtime.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,19 @@ No undefined behavior at runtime:
44

55
* Array access is bounds checked.
66
* Integer overflow is defined.
7+
8+
<details>
9+
10+
Key points:
11+
12+
* Integer overflow is defined via a compile-time flag. The options are
13+
either a panic (a controlled crash of the program) or wrap-around
14+
semantics. By default, you get panics in debug mode (`cargo build`)
15+
and wrap-around in release mode (`cargo build --release`).
16+
17+
* Bounds checking cannot be disabled with a compiler flag. It can also
18+
not be disabled directly with the `unsafe` keyword. However,
19+
`unsafe` allows you to call functions such as `slice::get_unchecked`
20+
which does not do bounds checking.
21+
22+
</details>

0 commit comments

Comments
 (0)