Skip to content

Commit 814ec74

Browse files
Merge branch 'slides/207-convert-google-rust-training-into-rst' into 'master'
Resolve "Convert Google Rust Training into RST" Closes #207 See merge request feng/training/material!274
2 parents 5448c3a + abc6adb commit 814ec74

File tree

146 files changed

+8584
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+8584
-0
lines changed

contrib/rst_files_with_prelude.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ courses/gnattest/*.rst
1010
courses/gnat_project_facility/*.rst
1111
courses/gnatcoverage/*.rst
1212
courses/rust_essentials/*.rst
13+
courses/comprehensive_rust_training/*.rst
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
************
2+
Introduction
3+
************
4+
5+
.. container:: PRELUDE BEGIN
6+
7+
.. container:: PRELUDE ROLES
8+
9+
.. role:: ada(code)
10+
:language: Ada
11+
12+
.. role:: C(code)
13+
:language: C
14+
15+
.. role:: cpp(code)
16+
:language: C++
17+
18+
.. role:: rust(code)
19+
:language: Rust
20+
21+
.. container:: PRELUDE SYMBOLS
22+
23+
.. |rightarrow| replace:: :math:`\rightarrow`
24+
.. |forall| replace:: :math:`\forall`
25+
.. |exists| replace:: :math:`\exists`
26+
.. |equivalent| replace:: :math:`\iff`
27+
.. |le| replace:: :math:`\le`
28+
.. |ge| replace:: :math:`\ge`
29+
.. |lt| replace:: :math:`<`
30+
.. |gt| replace:: :math:`>`
31+
.. |checkmark| replace:: :math:`\checkmark`
32+
33+
.. container:: PRELUDE REQUIRES
34+
35+
.. container:: PRELUDE PROVIDES
36+
37+
..
38+
About Adacore
39+
About This Training
40+
41+
.. container:: PRELUDE END
42+
43+
.. include:: 010_introduction/01-about_adacore.rst
44+
.. include:: 010_introduction/02-about_this_training.rst
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
=============
2+
About AdaCore
3+
=============
4+
5+
-----------
6+
The Company
7+
-----------
8+
9+
..
10+
Taken from https://www.adacore.com/company/about
11+
12+
* Founded in 1994
13+
* Centered around helping developers build **safe, secure and reliable** software
14+
* Headquartered in New York and Paris
15+
16+
- Representatives in countries around the globe
17+
18+
* Roots in Open Source software movement
19+
20+
- GNAT compiler is part of GNU Compiler Collection (GCC)
21+
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
===================
2+
About This Training
3+
===================
4+
5+
--------------------------
6+
Your Trainer
7+
--------------------------
8+
9+
* Experience in software development
10+
11+
- Languages
12+
- Methodology
13+
14+
* Experience teaching this class
15+
16+
-----------------------------
17+
Goals of the training session
18+
-----------------------------
19+
20+
* What you should know by the end of the training
21+
* Syllabus overview
22+
23+
- The syllabus is a guide, but we might stray off of it
24+
- ...and that's OK: we're here to cover **your needs**
25+
26+
----------
27+
Roundtable
28+
----------
29+
30+
* 5 minute exercise
31+
32+
- Write down your answers to the following
33+
- Then share it with the room
34+
35+
* Experience in software development
36+
37+
- Languages
38+
- Methodology
39+
40+
* Experience and interest with the syllabus
41+
42+
- Current and upcoming projects
43+
- Curious for something?
44+
45+
* Your personal goals for this training
46+
47+
- What do you want to have coming out of this?
48+
49+
* Anecdotes, stories... feel free to share!
50+
51+
- Most interesting or funny bug you've encountered?
52+
- Your own programming interests?
53+
54+
-------------------
55+
Course Presentation
56+
-------------------
57+
58+
* Slides
59+
* Quizzes
60+
* Labs
61+
62+
- Hands-on practice
63+
- Recommended setup: latest GNAT Studio
64+
- Class reflection after some labs
65+
66+
* Demos
67+
68+
- Depending on the context
69+
70+
* Daily schedule
71+
72+
--------
73+
Styles
74+
--------
75+
76+
* :dfn:`This` is a definition
77+
* :filename:`this/is/a.path`
78+
* :ada:`code is highlighted`
79+
* :command:`commands are emphasised --like-this`
80+
81+
.. warning:: This is a warning
82+
.. note:: This is an important piece of info
83+
.. tip:: This is a tip
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
*************
2+
Hello World
3+
*************
4+
5+
.. container:: PRELUDE BEGIN
6+
7+
.. container:: PRELUDE ROLES
8+
9+
.. role:: ada(code)
10+
:language: Ada
11+
12+
.. role:: C(code)
13+
:language: C
14+
15+
.. role:: cpp(code)
16+
:language: C++
17+
18+
.. role:: rust(code)
19+
:language: Rust
20+
21+
.. container:: PRELUDE SYMBOLS
22+
23+
.. |rightarrow| replace:: :math:`\rightarrow`
24+
.. |forall| replace:: :math:`\forall`
25+
.. |exists| replace:: :math:`\exists`
26+
.. |equivalent| replace:: :math:`\iff`
27+
.. |le| replace:: :math:`\le`
28+
.. |ge| replace:: :math:`\ge`
29+
.. |lt| replace:: :math:`<`
30+
.. |gt| replace:: :math:`>`
31+
.. |checkmark| replace:: :math:`\checkmark`
32+
33+
.. container:: PRELUDE REQUIRES
34+
35+
.. container:: PRELUDE PROVIDES
36+
37+
.. container:: PRELUDE END
38+
39+
.. include:: 020_hello_world/01_what_is_rust.rst
40+
.. include:: 020_hello_world/02_benefits.rst
41+
.. include:: 020_hello_world/03_playground.rst
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
===============
2+
What is Rust?
3+
===============
4+
5+
---------------
6+
What is Rust?
7+
---------------
8+
9+
Rust is a new programming language which had its `1.0 release in
10+
2015 <https://blog.rust-lang.org/2015/05/15/Rust-1.0.html>`__:
11+
12+
- Rust is a statically compiled language in a similar role as C++
13+
14+
- ``rustc`` uses LLVM as its backend.
15+
16+
- Rust supports many `platforms and
17+
architectures <https://doc.rust-lang.org/nightly/rustc/platform-support.html>`__:
18+
19+
- x86, ARM, WebAssembly, ...
20+
- Linux, Mac, Windows, ...
21+
22+
- Rust is used for a wide range of devices:
23+
24+
- firmware and boot loaders,
25+
- smart displays,
26+
- mobile phones,
27+
- desktops,
28+
- servers.
29+
30+
.. raw:: html
31+
32+
---------
33+
Details
34+
---------
35+
36+
Rust fits in the same area as C++:
37+
38+
- High flexibility.
39+
- High level of control.
40+
- Can be scaled down to very constrained devices such as
41+
microcontrollers.
42+
- Has no runtime or garbage collection.
43+
- Focuses on reliability and safety without sacrificing performance.
44+
45+
.. raw:: html
46+
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
==================
2+
Benefits of Rust
3+
==================
4+
5+
------------------
6+
Benefits of Rust
7+
------------------
8+
9+
Some unique selling points of Rust:
10+
11+
- *Compile time memory safety* - whole classes of memory bugs are
12+
prevented at compile time
13+
14+
- No uninitialized variables.
15+
- No double-frees.
16+
- No use-after-free.
17+
- No ``NULL`` pointers.
18+
- No forgotten locked mutexes.
19+
- No data races between threads.
20+
- No iterator invalidation.
21+
22+
- *No undefined runtime behavior* - what a Rust statement does is never
23+
left unspecified
24+
25+
- Array access is bounds checked.
26+
- Integer overflow is defined (panic or wrap-around).
27+
28+
- *Modern language features* - as expressive and ergonomic as
29+
higher-level languages
30+
31+
- Enums and pattern matching.
32+
- Generics.
33+
- No overhead FFI.
34+
- Zero-cost abstractions.
35+
- Great compiler errors.
36+
- Built-in dependency manager.
37+
- Built-in support for testing.
38+
- Excellent Language Server Protocol support.
39+
40+
.. raw:: html
41+
42+
---------
43+
Details
44+
---------
45+
46+
Do not spend much time here. All of these points will be covered in more
47+
depth later.
48+
49+
Make sure to ask the class which languages they have experience with.
50+
Depending on the answer you can highlight different features of Rust:
51+
52+
- Experience with C or C++: Rust eliminates a whole class of *runtime
53+
errors* via the borrow checker. You get performance like in C and
54+
C++, but you don't have the memory unsafety issues. In addition, you
55+
get a modern language with constructs like pattern matching and
56+
built-in dependency management.
57+
58+
- Experience with Java, Go, Python, JavaScript...: You get the same
59+
memory safety as in those languages, plus a similar high-level
60+
language feeling. In addition you get fast and predictable
61+
performance like C and C++ (no garbage collector) as well as access
62+
to low-level hardware (should you need it).
63+
64+
.. raw:: html
65+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
============
2+
Playground
3+
============
4+
5+
------------
6+
Playground
7+
------------
8+
9+
The `Rust Playground <https://play.rust-lang.org/>`__ provides an easy
10+
way to run short Rust programs, and is the basis for the examples and
11+
exercises in this course. Try running the "hello-world" program it
12+
starts with. It comes with a few handy features:
13+
14+
- Under "Tools", use the ``rustfmt`` option to format your code in the
15+
"standard" way.
16+
17+
- Rust has two main "profiles" for generating code: Debug (extra
18+
runtime checks, less optimization) and Release (fewer runtime checks,
19+
lots of optimization). These are accessible under "Debug" at the top.
20+
21+
- If you're interested, use "ASM" under "..." to see the generated
22+
assembly code.
23+
24+
.. raw:: html
25+
26+
---------
27+
Details
28+
---------
29+
30+
As students head into the break, encourage them to open up the
31+
playground and experiment a little. Encourage them to keep the tab open
32+
and try things out during the rest of the course. This is particularly
33+
helpful for advanced students who want to know more about Rust's
34+
optimizations or generated assembly.
35+
36+
.. raw:: html
37+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
******************
2+
Types And Values
3+
******************
4+
5+
.. container:: PRELUDE BEGIN
6+
7+
.. container:: PRELUDE ROLES
8+
9+
.. role:: ada(code)
10+
:language: Ada
11+
12+
.. role:: C(code)
13+
:language: C
14+
15+
.. role:: cpp(code)
16+
:language: C++
17+
18+
.. role:: rust(code)
19+
:language: Rust
20+
21+
.. container:: PRELUDE SYMBOLS
22+
23+
.. |rightarrow| replace:: :math:`\rightarrow`
24+
.. |forall| replace:: :math:`\forall`
25+
.. |exists| replace:: :math:`\exists`
26+
.. |equivalent| replace:: :math:`\iff`
27+
.. |le| replace:: :math:`\le`
28+
.. |ge| replace:: :math:`\ge`
29+
.. |lt| replace:: :math:`<`
30+
.. |gt| replace:: :math:`>`
31+
.. |checkmark| replace:: :math:`\checkmark`
32+
33+
.. container:: PRELUDE REQUIRES
34+
35+
.. container:: PRELUDE PROVIDES
36+
37+
.. container:: PRELUDE END
38+
39+
.. include:: 030_types_and_values/01_hello_world.rst
40+
.. include:: 030_types_and_values/02_variables.rst
41+
.. include:: 030_types_and_values/03_values.rst
42+
.. include:: 030_types_and_values/04_arithmetic.rst
43+
.. include:: 030_types_and_values/05_inference.rst
44+
.. include:: 030_types_and_values/06_exercise.rst

0 commit comments

Comments
 (0)