SlideShare a Scribd company logo
The Rust Programming Language
A gentle introduction
Mario A. Santini
Software Developer
Telco field
What is Rust
●
A language for system programming
●
Created by Mozilla (2010~, 2015 v1.0)
●
Multi paradigm, fast, productive and safe
●
“Fearless concurrency”
●
Community Driven and Open Source (MIT lic.)
Why we need it?
●
A replacement of C/C++ (mostly C++)
●
A powerfull type system
●
Zero cost of abstraction
●
Safety with the borrow checker
●
Highly memory controll without a GC
●
Rustup, cargo, rustfmt...
Where you should use it?
●
System code as alternative of C/C++ or where you
should have bindings with such libs
●
System code as an alternative of Java or Go where you
need more precise control of the memory (no GC)
●
Embedded applications
●
Bar metal
●
WebAssembly and more...
The strenghts?
●
Many concurrency bugs are almost impossible!
●
Strong memory handling checks!
●
Enums first class citizens!
●
Explicit error handling!
●
No NULL, null, nil…!
●
Powerfull Pattern Matching!
●
Macro!
...and more features…
●
Dependency handling included (cargo)
●
Documentation included (/// + rustdoc)
●
Linter included
●
Test/Examples/Bench included
●
RLS (rust-analyzer)...
Data Types
Length Signed Unsigned FP Bool Char
8-bit i8 u8 - true/false -
16-bit i16 u16 - - -
32-bit i32 u32 f32 - ‘ ’😻
64-bit i64 u64 f64 - -
128-bit i128 u128 - - -
arch isize usize - - -
Compund Types
tuple
array
Enum Struct Smart Pointer Raw Pointer Generics Trait
Strings Types
str
String
Ownership Rules
●
Each value in Rust has a variable that’s called its
owner
●
There can only be one owner at a time
●
When the owner goes out of scope, the value
will be dropped
Ownership some examples
let my_var = String::from(“Hello Developer Thursday!”);
require_ownership(my_var); // ← move ownership
println!(“My var {}”, my_var); // ← can’t be done!
…
let another_var = String::from(“Hi Developer Thursday!”);
just_borrow_it(&another_var); // ← notice the &
println!(“Another {}”, another_var); // ← now it’s fine!!
…
let mut mutable_var = String::from(“Hi ”);
requiere_mutable_borrow(&mut mutable_var); // this is possible as Rust guarantee there will
// just 1 reference to mutable_var
println!(“A mutable var {}”, mutable_var);
Lifetime
fn just_a_function<’a>(
haystack: &’a str, needle: &’a str
) → Option<&’a str> {
let found = haystack.find(needle)?;
let result = &haystack[found..needle.len()];
Some(reuslt.as_ref())
}
Ownership and structs
struct MyStruct { … }
impl MyStruct {
fn method_that_borrow(&self, …) { … }
fn method_with_mutable_borrow(&mut self, …) { … }
fn method_that_take_ownership(self, …) { … }
}
Multithreading vs Async
Multithreading → good for parallelization
Async → good for concurrecy
Native OS threads
async / .await
+ runtime
(tokio / async-std)
No Green Thread anymore in the language
But how fast it can be?
ripgrep: https://blog.burntsushi.net/ripgrep/
A closer look...
ripgrep: https://blog.burntsushi.net/ripgrep/
Discord Switching From Go to Rust
https://blog.discordapp.com/why-discord-is-switching-from-go-to-rust-a190bbca2b1f
Rust for the web
Seed: Rust framework for creating fast and reliable web apps with a structure that follows the Elm
Architecture.
Percy: A modular toolkit for building interactive frontend browser apps with Rust + WebAssembly.
Supports server side rendering.
Yew: Rust / Wasm client web app framework with architecture inspired by Elm and Redux. Yew is
based on stdweb that has a lot of features.
Draco: A Rust library for building client side web applications with WebAssembly modeled after the
Elm architecture and Redux.
Smithy: A front-end framework for writing WebAssembly applications entirely in Rust. Its goal is to
allow you to do so using idiomatic Rust, without giving up any of the compiler's safety guarantees.
squark: Rust frontend framework, for web browser and more with architecture inspired from Elm
and HyperApp.
Dodrio: A fast, bump-allocated virtual DOM library for Rust and WebAssembly.
rust-dominator: Zero cost declarative DOM library using FRP signals for Rust!
WASM
It’s a standard from W3C
Run inside the
browsers
Can be written in any
LLVM supported
language
Safe
Open and debuggable
Efficient and fast
It’s not JavaScript
https://webassembly.org/
WASM: Why Rust?
Rust
C/C++
AssemblyScript
TinyGo
Graalvm (just recently)
WASI
The WebAssembly System Interface
March 2019: Standardizing WASI: A system interface to run WebAssembly
outside the web
https://hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/
C / Rust
It’s a standard as a subgroup of the W3C
WebAssembly CG
https://wasi.dev/
Bytecode Alliance
Wastime
●
A runtime to run WASM + WASI application on the server
●
Written in Rust!
●
Safe as the application is sandboxed as it runs inside a browser
●
Fast as WASM is a compact and efficient format
●
Lightwight as you just need the runtime
●
Portable the format is standard on every architecture, just need the
runtime!
●
Polyglot wastime can be ported to different languages, and so you can
import librearies written in Rust and compiled in WASM and then
loaded as a Python module!
Krustlet
●
A kubelet rewritten in Rust, that runs WASM
programs
●
No need of containers images anymore
●
No need of an OS anymore!
●
And Krustlet can run without any OS too!!
Resources
●
Rust lang official site: https://www.rust-lang.org/
●
Crates.io: https://crates.io/
●
Rustup: https://rustup.rs/
●
Cargo: https://doc.rust-lang.org/cargo/
●
Rust book: https://doc.rust-lang.org/book/
●
Rustonomicon: https://doc.rust-lang.org/nomicon/
●
Rust by examples: https://doc.rust-lang.org/rust-by-example/
●
Rust cheat sheet: https://cheats.rs/
●
Rust users community: https://users.rust-lang.org/
●
Rust youtube channel: https://www.youtube.com/channel/UCaYhcUwRBNscFNUKTjgPFiA
●
Rust github: https://github.com/rust-lang/rust
●
Discord Rust streames channel: https://discord.com/channels/234804991343198210/749624598860922890
●
Rust playground: https://play.rust-lang.org/
●
Discord move to Rust: https://blog.discordapp.com/why-discord-is-switching-from-go-to-rust-a190bbca2b1f
●
WebAssembly: https://webassembly.org/
●
WASI: https://wasi.dev
●
Krustlet: https://github.com/deislabs/krustlet
●
Bytecode Alliance https://bytecodealliance.org/
Thanks!

More Related Content

PDF
Rust's Journey to Async/await
PDF
Deep drive into rust programming language
PDF
The Rust Programming Language: an Overview
PDF
Why rust?
ODP
Rust Primer
PDF
An introduction to Rust: the modern programming language to develop safe and ...
PDF
Why Rust? - Matthias Endler - Codemotion Amsterdam 2016
Rust's Journey to Async/await
Deep drive into rust programming language
The Rust Programming Language: an Overview
Why rust?
Rust Primer
An introduction to Rust: the modern programming language to develop safe and ...
Why Rust? - Matthias Endler - Codemotion Amsterdam 2016

What's hot (20)

PPT
Rust Programming Language
PDF
Introduction to rust: a low-level language with high-level abstractions
PDF
Rust: Systems Programming for Everyone
PDF
Introduction to Rust
PPTX
Introduction to Rust language programming
PDF
Rust system programming language
PDF
Rust: Unlocking Systems Programming
PDF
Livro pfsense 2.0 em português
PDF
Why your Spark job is failing
PPTX
Rust programming-language
PDF
Reactive Programming by UniRx for Asynchronous & Event Processing
PDF
Securing AEM webapps by hacking them
PPTX
Asynchronous programming
PPT
Presentazione Arduino
PDF
Introduce to Rust-A Powerful System Language
PPTX
Node js introduction
PPTX
Reverse Engineering of Rocket Chip
PPTX
Job Automation using Linux
PDF
Virtual machine and javascript engine
PPTX
Building an Empire with PowerShell
Rust Programming Language
Introduction to rust: a low-level language with high-level abstractions
Rust: Systems Programming for Everyone
Introduction to Rust
Introduction to Rust language programming
Rust system programming language
Rust: Unlocking Systems Programming
Livro pfsense 2.0 em português
Why your Spark job is failing
Rust programming-language
Reactive Programming by UniRx for Asynchronous & Event Processing
Securing AEM webapps by hacking them
Asynchronous programming
Presentazione Arduino
Introduce to Rust-A Powerful System Language
Node js introduction
Reverse Engineering of Rocket Chip
Job Automation using Linux
Virtual machine and javascript engine
Building an Empire with PowerShell
Ad

Similar to The Rust Programming Language (20)

PPTX
Rust Hack
PPT
Web Development Environments: Choose the best or go with the rest
PPTX
Legacy of Void*
PDF
Us 17-krug-hacking-severless-runtimes
PDF
Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...
PPTX
GOSIM 2024 - Porting Servo to OpenHarmony
PDF
Web (dis)assembly
PPTX
Adventures in Thread-per-Core Async with Redpanda and Seastar
PPTX
Introduction to Rust (Presentation).pptx
PDF
TypeScript, Dart, CoffeeScript and JavaScript Comparison
PDF
Introduction to Node.js
PPT
GWT is Smarter Than You
PDF
Techtalks: taking docker to production
PDF
JOSA TechTalk: Taking Docker to Production
PPTX
A Slice Of Rust - A quick look at the Rust programming language
PPTX
concept of server-side JavaScript / JS Framework: NODEJS
PDF
Node.js Course 2 of 2 - Advanced techniques
KEY
node.js: Javascript's in your backend
PDF
Jinx - Malware 2.0
PPTX
Web assembly with go
Rust Hack
Web Development Environments: Choose the best or go with the rest
Legacy of Void*
Us 17-krug-hacking-severless-runtimes
Apidays Paris 2023 - Forget TypeScript, Choose Rust to build Robust, Fast and...
GOSIM 2024 - Porting Servo to OpenHarmony
Web (dis)assembly
Adventures in Thread-per-Core Async with Redpanda and Seastar
Introduction to Rust (Presentation).pptx
TypeScript, Dart, CoffeeScript and JavaScript Comparison
Introduction to Node.js
GWT is Smarter Than You
Techtalks: taking docker to production
JOSA TechTalk: Taking Docker to Production
A Slice Of Rust - A quick look at the Rust programming language
concept of server-side JavaScript / JS Framework: NODEJS
Node.js Course 2 of 2 - Advanced techniques
node.js: Javascript's in your backend
Jinx - Malware 2.0
Web assembly with go
Ad

More from Mario Alexandro Santini (9)

PDF
A Safe Dock for our Programs
PDF
Rust With async / .await
PDF
Rust_Threads.pdf
PDF
The_Borrow_Checker.pdf
PDF
Introduction to typescript
PDF
The myth of the small script
ODP
Docker jug taa
PDF
Lambda architecture
A Safe Dock for our Programs
Rust With async / .await
Rust_Threads.pdf
The_Borrow_Checker.pdf
Introduction to typescript
The myth of the small script
Docker jug taa
Lambda architecture

Recently uploaded (20)

PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PDF
The Role of Automation and AI in EHS Management for Data Centers.pdf
PPTX
Materi-Enum-and-Record-Data-Type (1).pptx
PPTX
L1 - Introduction to python Backend.pptx
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
medical staffing services at VALiNTRY
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
Online Work Permit System for Fast Permit Processing
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PPTX
Transform Your Business with a Software ERP System
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
QAware_Mario-Leander_Reimer_Architecting and Building a K8s-based AI Platform...
PDF
Become an Agentblazer Champion Challenge Kickoff
Softaken Excel to vCard Converter Software.pdf
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Which alternative to Crystal Reports is best for small or large businesses.pdf
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
ManageIQ - Sprint 268 Review - Slide Deck
The Role of Automation and AI in EHS Management for Data Centers.pdf
Materi-Enum-and-Record-Data-Type (1).pptx
L1 - Introduction to python Backend.pptx
How Creative Agencies Leverage Project Management Software.pdf
medical staffing services at VALiNTRY
Odoo POS Development Services by CandidRoot Solutions
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Online Work Permit System for Fast Permit Processing
PTS Company Brochure 2025 (1).pdf.......
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
Transform Your Business with a Software ERP System
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
QAware_Mario-Leander_Reimer_Architecting and Building a K8s-based AI Platform...
Become an Agentblazer Champion Challenge Kickoff

The Rust Programming Language

  • 1. The Rust Programming Language A gentle introduction
  • 2. Mario A. Santini Software Developer Telco field
  • 3. What is Rust ● A language for system programming ● Created by Mozilla (2010~, 2015 v1.0) ● Multi paradigm, fast, productive and safe ● “Fearless concurrency” ● Community Driven and Open Source (MIT lic.)
  • 4. Why we need it? ● A replacement of C/C++ (mostly C++) ● A powerfull type system ● Zero cost of abstraction ● Safety with the borrow checker ● Highly memory controll without a GC ● Rustup, cargo, rustfmt...
  • 5. Where you should use it? ● System code as alternative of C/C++ or where you should have bindings with such libs ● System code as an alternative of Java or Go where you need more precise control of the memory (no GC) ● Embedded applications ● Bar metal ● WebAssembly and more...
  • 6. The strenghts? ● Many concurrency bugs are almost impossible! ● Strong memory handling checks! ● Enums first class citizens! ● Explicit error handling! ● No NULL, null, nil…! ● Powerfull Pattern Matching! ● Macro!
  • 7. ...and more features… ● Dependency handling included (cargo) ● Documentation included (/// + rustdoc) ● Linter included ● Test/Examples/Bench included ● RLS (rust-analyzer)...
  • 8. Data Types Length Signed Unsigned FP Bool Char 8-bit i8 u8 - true/false - 16-bit i16 u16 - - - 32-bit i32 u32 f32 - ‘ ’😻 64-bit i64 u64 f64 - - 128-bit i128 u128 - - - arch isize usize - - - Compund Types tuple array Enum Struct Smart Pointer Raw Pointer Generics Trait Strings Types str String
  • 9. Ownership Rules ● Each value in Rust has a variable that’s called its owner ● There can only be one owner at a time ● When the owner goes out of scope, the value will be dropped
  • 10. Ownership some examples let my_var = String::from(“Hello Developer Thursday!”); require_ownership(my_var); // ← move ownership println!(“My var {}”, my_var); // ← can’t be done! … let another_var = String::from(“Hi Developer Thursday!”); just_borrow_it(&another_var); // ← notice the & println!(“Another {}”, another_var); // ← now it’s fine!! … let mut mutable_var = String::from(“Hi ”); requiere_mutable_borrow(&mut mutable_var); // this is possible as Rust guarantee there will // just 1 reference to mutable_var println!(“A mutable var {}”, mutable_var);
  • 11. Lifetime fn just_a_function<’a>( haystack: &’a str, needle: &’a str ) → Option<&’a str> { let found = haystack.find(needle)?; let result = &haystack[found..needle.len()]; Some(reuslt.as_ref()) }
  • 12. Ownership and structs struct MyStruct { … } impl MyStruct { fn method_that_borrow(&self, …) { … } fn method_with_mutable_borrow(&mut self, …) { … } fn method_that_take_ownership(self, …) { … } }
  • 13. Multithreading vs Async Multithreading → good for parallelization Async → good for concurrecy Native OS threads async / .await + runtime (tokio / async-std) No Green Thread anymore in the language
  • 14. But how fast it can be? ripgrep: https://blog.burntsushi.net/ripgrep/
  • 15. A closer look... ripgrep: https://blog.burntsushi.net/ripgrep/
  • 16. Discord Switching From Go to Rust https://blog.discordapp.com/why-discord-is-switching-from-go-to-rust-a190bbca2b1f
  • 17. Rust for the web Seed: Rust framework for creating fast and reliable web apps with a structure that follows the Elm Architecture. Percy: A modular toolkit for building interactive frontend browser apps with Rust + WebAssembly. Supports server side rendering. Yew: Rust / Wasm client web app framework with architecture inspired by Elm and Redux. Yew is based on stdweb that has a lot of features. Draco: A Rust library for building client side web applications with WebAssembly modeled after the Elm architecture and Redux. Smithy: A front-end framework for writing WebAssembly applications entirely in Rust. Its goal is to allow you to do so using idiomatic Rust, without giving up any of the compiler's safety guarantees. squark: Rust frontend framework, for web browser and more with architecture inspired from Elm and HyperApp. Dodrio: A fast, bump-allocated virtual DOM library for Rust and WebAssembly. rust-dominator: Zero cost declarative DOM library using FRP signals for Rust!
  • 18. WASM It’s a standard from W3C Run inside the browsers Can be written in any LLVM supported language Safe Open and debuggable Efficient and fast It’s not JavaScript https://webassembly.org/
  • 20. WASI The WebAssembly System Interface March 2019: Standardizing WASI: A system interface to run WebAssembly outside the web https://hacks.mozilla.org/2019/03/standardizing-wasi-a-webassembly-system-interface/ C / Rust It’s a standard as a subgroup of the W3C WebAssembly CG https://wasi.dev/
  • 22. Wastime ● A runtime to run WASM + WASI application on the server ● Written in Rust! ● Safe as the application is sandboxed as it runs inside a browser ● Fast as WASM is a compact and efficient format ● Lightwight as you just need the runtime ● Portable the format is standard on every architecture, just need the runtime! ● Polyglot wastime can be ported to different languages, and so you can import librearies written in Rust and compiled in WASM and then loaded as a Python module!
  • 23. Krustlet ● A kubelet rewritten in Rust, that runs WASM programs ● No need of containers images anymore ● No need of an OS anymore! ● And Krustlet can run without any OS too!!
  • 24. Resources ● Rust lang official site: https://www.rust-lang.org/ ● Crates.io: https://crates.io/ ● Rustup: https://rustup.rs/ ● Cargo: https://doc.rust-lang.org/cargo/ ● Rust book: https://doc.rust-lang.org/book/ ● Rustonomicon: https://doc.rust-lang.org/nomicon/ ● Rust by examples: https://doc.rust-lang.org/rust-by-example/ ● Rust cheat sheet: https://cheats.rs/ ● Rust users community: https://users.rust-lang.org/ ● Rust youtube channel: https://www.youtube.com/channel/UCaYhcUwRBNscFNUKTjgPFiA ● Rust github: https://github.com/rust-lang/rust ● Discord Rust streames channel: https://discord.com/channels/234804991343198210/749624598860922890 ● Rust playground: https://play.rust-lang.org/ ● Discord move to Rust: https://blog.discordapp.com/why-discord-is-switching-from-go-to-rust-a190bbca2b1f ● WebAssembly: https://webassembly.org/ ● WASI: https://wasi.dev ● Krustlet: https://github.com/deislabs/krustlet ● Bytecode Alliance https://bytecodealliance.org/