Rust for High Level Developers

A presentation at KCDC 2023 in June 2023 in Kansas City, MO, USA by Ben Greenberg

Slide 1

Slide 1

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

Slide 2

Slide 2

Maybe your language of choice is…

Slide 3

Slide 3

Maybe your language of choice is…

Slide 4

Slide 4

Maybe your language of choice is…

Slide 5

Slide 5

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

Slide 6

Slide 6

My journey to Rust started with…

Slide 7

Slide 7

Slide 8

Slide 8

Slide 9

Slide 9

Slide 10

Slide 10

Slide 11

Slide 11

Slide 12

Slide 12

My months leading up to the Academy…

Slide 13

Slide 13

Slide 14

Slide 14

How will you start?

Slide 15

Slide 15

1 2 Getting Started Rust Syntax 3 4 Ownership Generics

Slide 16

Slide 16

Getting Started

Slide 17

Slide 17

Major Differences

Slide 18

Slide 18

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

Slide 19

Slide 19

Rust ● Compiled ● Static typing ● Manual memory management

Slide 20

Slide 20

Developer Ecosystem

Slide 21

Slide 21

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

Slide 22

Slide 22

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 23

Slide 23

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

Slide 24

Slide 24

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

Slide 25

Slide 25

Slide 26

Slide 26

That’s different than Rubygems 🤔

Slide 27

Slide 27

Syntax

Slide 28

Slide 28

A Quick Look

Slide 29

Slide 29

Slide 30

Slide 30

Slide 31

Slide 31

Slide 32

Slide 32

Type System

Slide 33

Slide 33

Slide 34

Slide 34

Slide 35

Slide 35

Slide 36

Slide 36

Memory and Ownership

Slide 37

Slide 37

Memory Management

Slide 38

Slide 38

Slide 39

Slide 39

Slide 40

Slide 40

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 41

Slide 41

Ownership

Slide 42

Slide 42

Slide 43

Slide 43

Slide 44

Slide 44

Slide 45

Slide 45

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

Slide 46

Slide 46

Generics

Slide 47

Slide 47

What are generics?

Slide 48

Slide 48

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

Slide 49

Slide 49

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

Slide 50

Slide 50

Why use generics?

Slide 51

Slide 51

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

Slide 52

Slide 52

Generics Syntax

Slide 53

Slide 53

Slide 54

Slide 54

It’s Reusable!

Slide 55

Slide 55

Slide 56

Slide 56

Slide 57

Slide 57

Slide 58

Slide 58

Continue Your Learning

Slide 59

Slide 59

Maybe you heard about the Rust book before…

Slide 60

Slide 60

Slide 61

Slide 61

Have you heard about the Brown University version?

Slide 62

Slide 62

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

Slide 63

Slide 63

Rustlings github.com/rust-lang/rustlings

Slide 64

Slide 64

Intro to Rust Course

Slide 65

Slide 65

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

Slide 66

Slide 66

Starting August 8th

Slide 67

Slide 67

Learning Rust from isn’t always easy

Slide 68

Slide 68

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

Slide 69

Slide 69

Let’s keep learning Rust together!