Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

intro and chapter 1 #4

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions slides/00-club-intro.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ title: Club Meetings
- Maybe live demo
- More info about editing: [this github repo](https://github.com/r4ds/bookclub-rust).
- Recorded, available on the [Data Science Learning Community YouTube Channel (DSLC.video)](http://dslc.video).
- [Sign up to present](https://docs.google.com/spreadsheets/d/1MbPzQ8hhM9Oi198_cj9w6cdtbsG9-eTAqv_W7_KFkYA/edit?gid=0#gid=0)

::: {.notes}
In case this is your first book club here, this is how things work.
We'll meet weekly and have a presentation followed by a discussion.

We're working through this book collaboratively so everyone is encouraged to present a session or two.
Please have a look at the schedule ASAP.
We need presenters for the next 2 weeks.
:::

## Pace

Expand All @@ -32,10 +42,23 @@ title: Club Meetings
- Ok to combine short chapters
- Meet ***every*** week except holidays, etc
- Ideally can discuss even if presenter unavailable
- Monday at 2:00 pm PST (2100 GMT)

::: {.notes}
The schedule will be consistent for the most part but if we need to make adjustments everyone will be notified well ahead of time.
For example, we will most likely meet for one of the scheduled holiday breaks or combine 2 chapters to one week.
Daylight savings in the spring comes right at the end of schedule and is particularly gnarly this year I'd like to finish before then.
:::

## Learning objectives (LOs)

- Students who study with LOs in mind ***retain more.***
- **Tips:**
- "After today's session, you will be able to..."
- *Very* roughly **1 per section.**

::: {.notes}
When writing your presentation it can help to define learning objectives.
This can help you identify the key points of the chapter, which also helps everyone else.
It's not strictly required though so don't stress about it.
:::
27 changes: 1 addition & 26 deletions slides/00-intro.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,4 @@ engine: knitr
title: Introduction
---

# Learning objectives

::: nonincremental
- THESE ARE NICE TO HAVE BUT NOT ABSOLUTELY NECESSARY
:::

::: notes
- You can add notes on each slide with blocks like this!
- Load a deck in the browser and type "s" to see these notes.
:::

# SLIDE SECTION

## SLIDE

- DENOTE MAJOR SECTIONS WITH `# TITLE` (eg `# Installation`)
- ADD INDIVIDUAL SLIDES WITH `##` (eg `## rustup on Linux/macOS`)
- KEEP THEM RELATIVELY SLIDE-LIKE; THESE ARE NOTES, NOT THE BOOK ITSELF.

## SLIDE

# SLIDE SECTION

## SLIDE

## SLIDE
Note: the introduction is minimal so we combined it with chapter 1.
159 changes: 146 additions & 13 deletions slides/01-getting_started.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,160 @@ title: "1. Getting Started"

# Learning objectives

By the end of this session you should be able to...

::: nonincremental
- THESE ARE NICE TO HAVE BUT NOT ABSOLUTELY NECESSARY
- answer the question "Why Rust?"
- run a hello, world program
- understand how to manage projects with `cargo`
:::

::: notes
- You can add notes on each slide with blocks like this!
- Load a deck in the browser and type "s" to see these notes.
## Rust

> A language empowering everyone to build reliable and efficient software.

::: {.notes}
Let's get started.

Rust says it's a 'language empowering ...'
The key words that stick out for me are 'reliable' and 'efficient.'

If you're like me, those are the main selling points you've heard related to rust.
Rust is _efficient_, both in terms of run time and development time.
And Rust is _reliable_, eliminating bugs related to memory management that come up in languages like C.

By the end of this book, we should have an idea of how well Rust holds up to those statements.
:::

# SLIDE SECTION

## SLIDE
## Set up

- Install Rust
- Choose an editor
- Install extensions


::: {.notes}
I assume you can install Rust but if you have issues we can help shortly.

It's likely many of us have only used R and RStudio.
If that's the case, I want to point out some differences you'll encounter.

Both R and RStudio come with everything you need to write R code.
However, with other languges and editors, you often need to install tools specific to that language.
For example, language servers, debuggers, and package managers.
You most definitely want to install the Rust tooling for whatever editor you use.

If you aren't sure, I recommend using Visual Studio Code with the rust-analyzer extension.
You will also need an extension with debugging support.
You can find a link in the rust-analyzer extension.
Again, if you need help with this, we can get to that shortly.
:::


## Hello, World

```rust
fn main() {
println!("Hello, world!");
}
```

- `fn main()` is required in `main.rs`
- The `!` in `println!` means macro
- The `;` is required


::: {.notes}
This is the obligatory hello world.
Since this is a simple program, it's clear what's going on.

But there are some details worth pointing out.

Every rust program has a `main.rs` file with a `main` function in it.
This is the entrypoint to the program, the first thing that get's run.

The `!` in `println!` means `println` is a macro.
A macro is sort of like a function.
That's a sufficient understanding for now.
We'll get to the details of what a macro is later in the book.

Lastly, note the `;` which indicated the end of an expression.
This is generally required for every statement you write.
:::

## Compile and run

- DENOTE MAJOR SECTIONS WITH `# TITLE` (eg `# Installation`)
- ADD INDIVIDUAL SLIDES WITH `##` (eg `## rustup on Linux/macOS`)
- KEEP THEM RELATIVELY SLIDE-LIKE; THESE ARE NOTES, NOT THE BOOK ITSELF.

## SLIDE
```bash
rustc main.rs
```

# SLIDE SECTION
```bash
./main
```

## SLIDE
::: {.notes}
Rust is a compiled language so we have to run the compiler `rustc` first.

If you've never used a compiled language before, compiling is the process of translating the Rust code you write into a language the computer can read.
With interpreted languages like R or Python, this translation happens on the fly.
But with a compiled language, you have to translate the program before it can run.

Once compiled, you'll have an executable file that you can now run.
On Mac/Linux, it will be `main`.
On Windows, it will be `main.exe`.
:::


## Cargo

```toml
[package]
name = "hello_cargo"
version = "0.1.0"
edition = "2021"

[dependencies]
```


::: {.notes}
Unlike R, where installing dependencies is built into the language, Rust has a separate program for this called `cargo`.
With `cargo`, you define your dependencies, among other things, in a TOML file.
:::

## Cargo

::::: nonincremental
:::: {.columns}

::: {.column}
- `cargo new project_name`
- `Cargo.toml`
- `cargo.lock`
:::

::: {.column}
- `project_name/.Rproj`
- `DESCRIPTION`
- `renv.lock`
:::

::::

:::::

::: {.notes}
More than installing dependencies though, `cargo` helps you manage your Rust projects.
It let's you create projects, install dependencies, compile, and run your project.

A cargo project is like an RStudio project.

`Cargo.toml` is like `DESCRIPTION` in an R package.

And cargo tracks dependency versions with `cargo.lock`, which is like `renv.lock`.

:::

## SLIDE
## Discussion
Loading