Rust for High Level Developers

A presentation at THAT Conference, WI 2023 in July 2023 in Wisconsin Dells, WI, USA by Ben Greenberg

Slide 1

Slide 1

From High-Level to Systems Programming: A Practical Guide to Rust

Slide 2

Slide 2

Slide 3

Slide 3

Maybe your language of choice is…

Slide 4

Slide 4

Maybe your language of choice is…

Slide 5

Slide 5

Maybe your language of choice is…

Slide 6

Slide 6

And now you want to learn Rust How do you start?

Slide 7

Slide 7

My journey to Rust started with…

Slide 8

Slide 8

Slide 9

Slide 9

Slide 10

Slide 10

Slide 11

Slide 11

Slide 12

Slide 12

Slide 13

Slide 13

My months leading up to the Academy…

Slide 14

Slide 14

Slide 15

Slide 15

How will you start?

Slide 16

Slide 16

1 2 Getting Started Rust Syntax 3 4 Ownership Generics

Slide 17

Slide 17

Getting Started

Slide 18

Slide 18

Major Differences

Slide 19

Slide 19

JavaScript Python Ruby ● Interpreted ● Dynamic typing ● Garbage collected ● Interpreted ● Dynamic typing ● Garbage collected ● Interpreted ● Dynamic typing ● Garbage collected

Slide 20

Slide 20

Rust ● Compiled ● Static typing ● Manual memory management

Slide 21

Slide 21

Developer Ecosystem

Slide 22

Slide 22

“Rust is on its seventh year as the most loved language with 87% of developers saying they want to continue using it.”

Slide 23

Slide 23

To name a few… Web development: Actix, Rocket, Tide Async programming: Tokio, async-std Growing ecosystem of libraries and tools Serialization: Serde Blockchain: Substrate, ink! Database ORMs: Diesel, sqlx, Cryptography and security: scale, ring, rustls GUI development: druid, iced Game development: Amethyst, Bevy, ggez

Slide 24

Slide 24

  • Regular release cycle Actively being improved and developed
  • Community-driven RFC process - Focus on ergonomics, performance and stability - Strong emphasis on backward compatibility

Slide 25

Slide 25

Cargo: Package Manager and build tool crates.io: Package registry

Slide 26

Slide 26

Slide 27

Slide 27

That’s different than Rubygems 🤔

Slide 28

Slide 28

Syntax

Slide 29

Slide 29

A Quick Look

Slide 30

Slide 30

Slide 31

Slide 31

Slide 32

Slide 32

Slide 33

Slide 33

Type System

Slide 34

Slide 34

Slide 35

Slide 35

Slide 36

Slide 36

Slide 37

Slide 37

Memory and Ownership

Slide 38

Slide 38

Memory Management

Slide 39

Slide 39

Slide 40

Slide 40

Slide 41

Slide 41

JavaScript relies on garbage collection to free memory from previous large arrays, which may introduce performance overhead. Rust deallocates memory as soon as it’s no longer needed, providing efficient and deterministic memory management.

Slide 42

Slide 42

Ownership

Slide 43

Slide 43

Slide 44

Slide 44

Slide 45

Slide 45

Slide 46

Slide 46

Once Pac-man (i.e. Rust) consumes (i.e. owns) the ball, it’s no longer available

Slide 47

Slide 47

Generics

Slide 48

Slide 48

What are generics?

Slide 49

Slide 49

Generics allow writing flexible, reusable, and type-safe code without specifying concrete data types

Slide 50

Slide 50

Create functions, structs, enums, and traits that work with multiple data types

Slide 51

Slide 51

Why use generics?

Slide 52

Slide 52

Generics provide a way to achieve flexibility similar to dynamically typed languages while maintaining type safety benefits of static typing

Slide 53

Slide 53

Generics Syntax

Slide 54

Slide 54

Slide 55

Slide 55

It’s Reusable!

Slide 56

Slide 56

Slide 57

Slide 57

Slide 58

Slide 58

Slide 59

Slide 59

Continue Your Learning

Slide 60

Slide 60

Maybe you heard about the Rust book before…

Slide 61

Slide 61

Slide 62

Slide 62

Have you heard about the Brown University version?

Slide 63

Slide 63

https://rust-book.cs.brown.edu/

Slide 64

Slide 64

Rustlings github.com/rust-lang/rustlings

Slide 65

Slide 65

Intro to Rust Course

Slide 66

Slide 66

https://w3f.github.io/w3f-education/docs/introrust

Slide 67

Slide 67

Streaming every week!

Slide 68

Slide 68

Learning Rust from isn’t always easy

Slide 69

Slide 69

But, with the right resources and community it is possible!

Slide 70

Slide 70

Let’s keep learning Rust together!

Slide 71

Slide 71