SlideShare a Scribd company logo
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 1/49
RUSTRUST
Be pinched by a cBe pinched by a cRUSTRUSTacean to prevent programmingacean to prevent programming
errors !errors !
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 2/49
2 words about us2 words about us
$ cat ~/.bash_profile
NAME="René Ribaud"
AGE=43
source ./1998.sh
PROFESSION="Unices system and storage" 
"administrator , since 2003"
HISTORY="Lots (too many) infrastructure" 
"implementation projects" 
"Discover Linux & FLOSS between" 
"1995 / 2000" 
"First step in the cloud around 2011" 
", pre-sales solution architect" 
"2014 (Cloud, DevOps)" 
"I’m an Ops !"
COMPANY="CGI 20th November 2017"
JOB="Information system architect" 
"specialized around DevOps technologies"
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 3/49
2 words about us2 words about us
François BestFrançois Best
Freelance Developer
Embedded/Realtime C/C++
background
Seduced by the Dark Side of the Web
Current interests:
Rust (of course)
Security / Cryptography
Decentralisation
Personal data protection
& de-GAFAMing
Github: |
Web:
@franky47
@47ng
francoisbest.com
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 4/49
What is RUST ?What is RUST ?
New systems programming language
Multi paradigm language (imperative, functional, object
oriented (not fully))
By Mozilla and the Community
Dual license MIT and Apache v2.0
First stable release May 15th, 2015
Rust 2018 (v1.31), a major new edition released
December 6th, 2018
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 5/49
Goal ?Goal ?
Provide an alternative to C/C++ and also higher-levelProvide an alternative to C/C++ and also higher-level
languageslanguages
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 6/49
Why is this Ops guy speaking about aWhy is this Ops guy speaking about a
programming language ?programming language ?
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 7/49
Immune to coder disease 1Immune to coder disease 1
My language is the best !My language is the best !
And my code is also the best !And my code is also the best !
This is part of my job to know languages and especially how to build projects usingThis is part of my job to know languages and especially how to build projects using
themthem
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 8/49
Immune to coder disease 2Immune to coder disease 2
I don't make mistakes, only bad coders are making onesI don't make mistakes, only bad coders are making ones
Really, how do you explain all major projects security issues ?Really, how do you explain all major projects security issues ?
I'm fed up about segfaults and null pointer exceptions !I'm fed up about segfaults and null pointer exceptions !
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 9/49
Why is RUST exciting to me ?Why is RUST exciting to me ?
And probably why should you look at it ?And probably why should you look at it ?
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 10/49
PromisesPromises
Focus on safety -> avoids errors and helps finding them
!
Especially safe concurrency
Fast, really fast !
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 11/49
But alsoBut also
Compiled language, few runtime dependencies
Produces binaries, that could be static with musl
Can interact easily with other languages via ABI and
bindings (Python, C/C++, JS...)
State of mind, hard at compile time, but safe at runtime
Somewhere challenging !
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 12/49
Ripgrep (rg)Ripgrep (rg)
An application written in RustAn application written in Rust
A grep enhanced
Compatible with standard grep
Search speed is really
impressive
Look also at fd, exa, lsd...
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 13/49
And a cute mascot !And a cute mascot !
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 14/49
What it looks likeWhat it looks like
extern crate flate2;
use flate2::read::GzDecoder;
use std::fs::File;
use std::io::Read;
fn run() -> String {
let path = "ascii.txt.gz";
let mut contents = String::new();
let gz = File::open(path).unwrap(); // open and decompress file
let mut uncompress = GzDecoder::new(gz);
uncompress.read_to_string(&mut contents).unwrap();
contents // return implicitly contents
}
fn main() {
println!("Hello, world!");
let result = run(); // call run function
println!("{}", result); // display compress file content
}
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 15/49
Language featuresLanguage features
Static type system with local type
inference
Explicit mutability
Zero-cost abstractions
Runtime-independent concurrency safety
Errors are values
No null
Static automatic memory management
No garbage collection
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 16/49
Safety is achieved by mainly 3 conceptsSafety is achieved by mainly 3 concepts
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 17/49
MutabilityMutability
struct Bike {
speed: u32,
distance: u32,
brand: String,
}
fn main() {
let mybike = Bike {
speed: 25,
distance: 1508,
brand: "Liteville".to_string(),
};
mybike.speed = 30; //Reassign !!!
println!(
"Bike {}: speed={} distance={}",
mybike.brand, mybike.speed, mybike.distance
);
}
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 18/49
Mutability errorMutability error
error[E0594]: cannot assign to field `mybike.speed` of immutable binding
--> src/main.rs:14:5
|
8 | let mybike = Bike {
| ------ help: make this binding mutable: `mut mybike`
...
14 | mybike.speed = 30; //Reassign !!!
| ^^^^^^^^^^^^^^^^^ cannot mutably borrow field of immutable binding
error: aborting due to previous error
For more information about this error, try `rustc --explain E0594`.
error: Could not compile `immutability`.
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 19/49
Ownership & BorrowingOwnership & Borrowing
Every piece of data is uniquely owned
Ownership can be passed
When owned data reaches the end of a scope, it is
destroyed
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 20/49
OwnershipOwnership
fn main() {
let s1 = String::from("Hello, RUST ! 🦀");
let s2 = s1;
println!("{}", s1);
}
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 21/49
Ownership errorOwnership error
--> src/main.rs:3:9
|
3 | let s2 = s1;
|
= note: #[warn(unused_variables)] on by default
error[E0382]: borrow of moved value: `s1`
--> src/main.rs:4:20
|
3 | let s2 = s1;
| -- value moved here
4 | println!("{}", s1);
| ^^ value borrowed here after move
|
= note: move occurs because `s1` has type
`std::string::String`, which does not implement the `Copy` trait
error: aborting due to previous error
For more information about this error, try `rustc --explain E0382`.
error: Could not compile `owned2`.
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 22/49
OwnershipOwnership
fn main() {
let s = String::from("Hello, RUST ! 🦀");
display(s);
display(s); // Already owned !
}
fn display(some_string: String) {
println!("{}", some_string);
}
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 23/49
Ownership errorOwnership error
error[E0382]: use of moved value: `s`
--> src/main.rs:5:13
|
4 | display(s);
| - value moved here
5 | display(s); // Already owned !
| ^ value used here after move
|
= note: move occurs because `s` has type `std::string::String`,
which does not implement the `Copy` trait
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 24/49
Ownership & BorrowingOwnership & Borrowing
Access can be borrowed (mutable and
immutable)
You can borrow mutably once
Or multiple times immutably
Exclusive: mutable or immutable, never both
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 25/49
BorrowingBorrowing
fn main() {
let s = String::from("Hello, RUST ! 🦀");
display(&s);
display(&s);
}
fn display(some_string: &String) {
println!("{}", some_string);
}
Hello, RUST ! 🦀
Hello, RUST ! 🦀
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 26/49
Borrowing mutableBorrowing mutable
fn main() {
let s = String::from("Hello");
change(&s);
println!("{}", s);
}
fn change(some_string: &String) {
some_string.push_str(", RUST ! 🦀");
}
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 27/49
Borrowing mutable errorBorrowing mutable error
error[E0596]: cannot borrow immutable borrowed content `*some_string` as mutable
--> src/main.rs:9:5
|
8 | fn change(some_string: &String) {
| ------- use `&mut String` here to make mutable
9 | some_string.push_str(", RUST ! 🦀");
| ^^^^^^^^^^^ cannot borrow as mutable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0596`.
error: Could not compile `borrow_mut`.
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 28/49
Borrowing mutable fixedBorrowing mutable fixed
fn main() {
let mut s = String::from("Hello");
change(&mut s);
println!("{}", s);
}
fn change(some_string: &mut String) {
some_string.push_str(", RUST ! 🦀");
}
Hello, RUST ! 🦀
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 29/49
References validity checksReferences validity checks
#[derive(Debug)]
struct Person<'a> {
first_name: &'a str,
last_name: &'a str,
age: &'a i32,
phone: Vec<&'a str>,
}
fn return_reference<'a>() -> Person<'a> {
let age = 25;
Person {
first_name: "John",
last_name: "Doe",
age: &age,
phone: vec!["123-123", "456-456"],
}
}
fn main() {
let person = return_reference();
println!("{:?}", person);
}
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 30/49
References validity checks errorReferences validity checks error
error[E0597]: `age` does not live long enough
--> src/main.rs:15:15
|
15 | age: &age,
| ^^^ borrowed value does not live long enough
...
18 | }
| - borrowed value only lives until here
|
note: borrowed value must be valid for the lifetime 'a as defined on the function
body at 9:1...
--> src/main.rs:9:1
|
9 | fn return_reference<'a>() -> Person<'a> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0597`.
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 31/49
Concurrency without fearConcurrency without fear
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 32/49
Concurrency without fearConcurrency without fear
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 33/49
Concurrency without fear errorConcurrency without fear error
Rust type system allows no data racesRust type system allows no data races
error[E0596]: cannot borrow `words` as mutable, as it is a captured variable
in a `Fn` closure
--> src/main.rs:19:54
|
19 | .for_each(|arg| tally_words(arg.to_string(), &mut words).unwrap());
| ^^^^^^^^^^ cannot borrow
as mutable
|
help: consider changing this to accept closures that implement `FnMut`
--> src/main.rs:19:19
|
19 | .for_each(|arg| tally_words(arg.to_string(), &mut words).unwrap());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0596`.
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 34/49
High level abstractionHigh level abstraction
Generics and TraitsGenerics and Traits
Define shared behavior
Define behavior based on types
Define behavior from various types with trait
bounds
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 35/49
Unsafe RustUnsafe Rust
Allow to disengage some safety features
Use at your own risk !
Crates using unsafe code can be audited with cargo-
geiger
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 36/49
A modern languageA modern language
with builtin code quality standardswith builtin code quality standards
Documentation embedded into code
Unit tests
Integration tests
Great documentation (books and std
lib)
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 37/49
A modern languageA modern language
with tools to be productivewith tools to be productive
Environment setup and update rustup
Package (crates) management cargo + plugin
Code formatting rustfmt
Compiler rustc
Efficient error messages
Potential solution
Linter clippy
Code completion racer
Help transition to 2018 edition rustfix
Editor integration (IntelliJ, Vs code, Vim,
Emacs...)
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 38/49
Opinionated for productivityOpinionated for productivity
Avoiding bikesheddingAvoiding bikeshedding
Crates have a defined filesystem structure
Modules & exports based on file location (like Python)
But with control over public / private exports (like
ES6)
Batteries included, but replaceable
Procedural macros for DSLs (eg: JSON, CSS...)
Custom compile-time extensions with build scripts
Cargo extensions with cargo-foo binary crates
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 39/49
Interesting cratesInteresting crates
That extend the std libThat extend the std lib
Date and time management chrono
Parallel iteration rayon
HTTP client reqwest
Command line parsing clap, docopt,
structopt
Logging log
Serialization serde
Regular expressions regex
...
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 40/49
Area of useArea of use
Command line tools
Web and network
services
Embedded device, IOT
WebAssembly
Games
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 41/49
Who is using Rust ?Who is using Rust ?
Mozilla, servo project
RedHat, stratis
project
Dropbox
Telenor
Chef
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 42/49
Who is using Rust ?Who is using Rust ?
Ready at dawn
Chucklefish that published Stardew Valley and Starbound,
is using Rust in their new projects Wargroove and
Witchbrook to get safe concurrency and portability
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 43/49
Who is using Rust ?Who is using Rust ?
Clevercloud, (Geoffroy Couprie)
nom, parser
Sozu, reverse proxy
Snips
ANSSI: RFC for secure application design in
Rust
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 44/49
Governance and communityGovernance and community
Rust is pragmaticRust is pragmatic
All features are driven by needs of real software
The language is evolved with user feedback
Consciously chooses familiar constructs
Picks good ideas from others
Doesn’t want to be the primary language at all
cost
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 45/49
Governance and communityGovernance and community
Beloved language and communityBeloved language and community
Voted "Most loved language" on Stackoverflow 2018,
2017, 2016
Only 1/100 of survey respondents have issues with the
Rust community
Newcomers from all directions
https://insights.stackoverflow.com/survey/2018/#most-loved-dreaded-and-wantedhttps://insights.stackoverflow.com/survey/2018/#most-loved-dreaded-and-wanted
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 46/49
Governance and communityGovernance and community
growthgrowth
https://8-p.info/visualizing-crates-io/https://8-p.info/visualizing-crates-io/
Crates.ioCrates.io
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 47/49
Governance and communityGovernance and community
Help from the communityHelp from the community
Lots of books
IRC and Discord
channels
User forum
Youtube channel
Meetups
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 48/49
Governance and communityGovernance and community
Beloved language and communityBeloved language and community
Experience from Mozilla to drive open projects
All major decisions, go to an open Request For
Comments process
Release every 6 weeks
3 channels: stable, beta and nightly
Medium time to merged PR for changes: 6 days!
More then 4/5 of contributions to the Rust language come
from outside Mozilla
The compiler has more then 2000 contributors
3/27/2019 Be pinched by a cRUSTacean to prevent programming errors !
localhost:8000/rust/?print-pdf#/ 49/49
THANK YOUTHANK YOU
René Ribaud <rene.ribaud@cgi.com>
François Best
<contact@francoisbest.com>

More Related Content

What's hot (13)

PDF
Perl Dancer for Python programmers
xSawyer
 
ODP
Perl Moderno
Tiago Peczenyj
 
PDF
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
ZFConf Conference
 
PDF
The Puppet Debugging Kit: Building Blocks for Exploration and Problem Solving...
Puppet
 
PPT
Happy porting x86 application to android
Owen Hsu
 
PPTX
How to build a slack-hubot with js
Juneyoung Oh
 
PDF
Composer the right way - SunshinePHP
Rafael Dohms
 
PDF
Cross Building the FreeBSD ports tree by Baptiste Daroussin
eurobsdcon
 
PDF
To swiftly go where no OS has gone before
Paul Ardeleanu
 
PDF
Quick Intro To JRuby
Frederic Jean
 
PPTX
Connecting C++ and JavaScript on the Web with Embind
Chad Austin
 
PPT
Rush, a shell that will yield to you
guestdd9d06
 
PPTX
Webinar - Windows Application Management with Puppet
OlinData
 
Perl Dancer for Python programmers
xSawyer
 
Perl Moderno
Tiago Peczenyj
 
ZFConf 2012: Capistrano для деплоймента PHP-приложений (Роман Лапин)
ZFConf Conference
 
The Puppet Debugging Kit: Building Blocks for Exploration and Problem Solving...
Puppet
 
Happy porting x86 application to android
Owen Hsu
 
How to build a slack-hubot with js
Juneyoung Oh
 
Composer the right way - SunshinePHP
Rafael Dohms
 
Cross Building the FreeBSD ports tree by Baptiste Daroussin
eurobsdcon
 
To swiftly go where no OS has gone before
Paul Ardeleanu
 
Quick Intro To JRuby
Frederic Jean
 
Connecting C++ and JavaScript on the Web with Embind
Chad Austin
 
Rush, a shell that will yield to you
guestdd9d06
 
Webinar - Windows Application Management with Puppet
OlinData
 

Similar to Be pinched by a cRUSTacean to prevent programming errors ! (20)

PDF
Intro to Rust 2019
Timothy Bess
 
ODP
Introduction To Rust
Knoldus Inc.
 
PDF
Rust: Reach Further (from QCon Sao Paolo 2018)
nikomatsakis
 
PPTX
Introduction to Rust (Presentation).pptx
Knoldus Inc.
 
ODP
Rust Primer
Knoldus Inc.
 
PDF
Rust: Reach Further
nikomatsakis
 
PDF
Le langage rust
Geeks Anonymes
 
PDF
Rust: Systems Programming for Everyone
C4Media
 
PDF
Rust Intro @ Roma Rust meetup
Claudio Capobianco
 
PDF
Embedded Rust on IoT devices
Lars Gregori
 
PPTX
The Rust Programming Language vs The C Programming Language
jmquimosing
 
PDF
The Rust Programming Language
Mario Alexandro Santini
 
PPT
Rust Programming Language
Jaeju Kim
 
PDF
Introduction to Rust - Waterford Tech Meetup 2025
John Rellis
 
PDF
Rust and Eclipse
Max Bureck
 
PPTX
Rust Intro
Arthur Gavkaluk
 
PDF
Why rust?
Mats Kindahl
 
PPTX
Rust vs C++
corehard_by
 
PDF
Rust "Hot or Not" at Sioux
nikomatsakis
 
PDF
Introduction to Rust
João Oliveira
 
Intro to Rust 2019
Timothy Bess
 
Introduction To Rust
Knoldus Inc.
 
Rust: Reach Further (from QCon Sao Paolo 2018)
nikomatsakis
 
Introduction to Rust (Presentation).pptx
Knoldus Inc.
 
Rust Primer
Knoldus Inc.
 
Rust: Reach Further
nikomatsakis
 
Le langage rust
Geeks Anonymes
 
Rust: Systems Programming for Everyone
C4Media
 
Rust Intro @ Roma Rust meetup
Claudio Capobianco
 
Embedded Rust on IoT devices
Lars Gregori
 
The Rust Programming Language vs The C Programming Language
jmquimosing
 
The Rust Programming Language
Mario Alexandro Santini
 
Rust Programming Language
Jaeju Kim
 
Introduction to Rust - Waterford Tech Meetup 2025
John Rellis
 
Rust and Eclipse
Max Bureck
 
Rust Intro
Arthur Gavkaluk
 
Why rust?
Mats Kindahl
 
Rust vs C++
corehard_by
 
Rust "Hot or Not" at Sioux
nikomatsakis
 
Introduction to Rust
João Oliveira
 
Ad

Recently uploaded (20)

PPTX
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
PDF
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
July Patch Tuesday
Ivanti
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Webinar: Introduction to LF Energy EVerest
DanBrown980551
 
What Makes Contify’s News API Stand Out: Key Features at a Glance
Contify
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Chris Elwell Woburn, MA - Passionate About IT Innovation
Chris Elwell Woburn, MA
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
July Patch Tuesday
Ivanti
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Using FME to Develop Self-Service CAD Applications for a Major UK Police Force
Safe Software
 
Ad

Be pinched by a cRUSTacean to prevent programming errors !

  • 1. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 1/49 RUSTRUST Be pinched by a cBe pinched by a cRUSTRUSTacean to prevent programmingacean to prevent programming errors !errors !
  • 2. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 2/49 2 words about us2 words about us $ cat ~/.bash_profile NAME="René Ribaud" AGE=43 source ./1998.sh PROFESSION="Unices system and storage" "administrator , since 2003" HISTORY="Lots (too many) infrastructure" "implementation projects" "Discover Linux & FLOSS between" "1995 / 2000" "First step in the cloud around 2011" ", pre-sales solution architect" "2014 (Cloud, DevOps)" "I’m an Ops !" COMPANY="CGI 20th November 2017" JOB="Information system architect" "specialized around DevOps technologies"
  • 3. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 3/49 2 words about us2 words about us François BestFrançois Best Freelance Developer Embedded/Realtime C/C++ background Seduced by the Dark Side of the Web Current interests: Rust (of course) Security / Cryptography Decentralisation Personal data protection & de-GAFAMing Github: | Web: @franky47 @47ng francoisbest.com
  • 4. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 4/49 What is RUST ?What is RUST ? New systems programming language Multi paradigm language (imperative, functional, object oriented (not fully)) By Mozilla and the Community Dual license MIT and Apache v2.0 First stable release May 15th, 2015 Rust 2018 (v1.31), a major new edition released December 6th, 2018
  • 5. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 5/49 Goal ?Goal ? Provide an alternative to C/C++ and also higher-levelProvide an alternative to C/C++ and also higher-level languageslanguages
  • 6. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 6/49 Why is this Ops guy speaking about aWhy is this Ops guy speaking about a programming language ?programming language ?
  • 7. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 7/49 Immune to coder disease 1Immune to coder disease 1 My language is the best !My language is the best ! And my code is also the best !And my code is also the best ! This is part of my job to know languages and especially how to build projects usingThis is part of my job to know languages and especially how to build projects using themthem
  • 8. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 8/49 Immune to coder disease 2Immune to coder disease 2 I don't make mistakes, only bad coders are making onesI don't make mistakes, only bad coders are making ones Really, how do you explain all major projects security issues ?Really, how do you explain all major projects security issues ? I'm fed up about segfaults and null pointer exceptions !I'm fed up about segfaults and null pointer exceptions !
  • 9. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 9/49 Why is RUST exciting to me ?Why is RUST exciting to me ? And probably why should you look at it ?And probably why should you look at it ?
  • 10. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 10/49 PromisesPromises Focus on safety -> avoids errors and helps finding them ! Especially safe concurrency Fast, really fast !
  • 11. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 11/49 But alsoBut also Compiled language, few runtime dependencies Produces binaries, that could be static with musl Can interact easily with other languages via ABI and bindings (Python, C/C++, JS...) State of mind, hard at compile time, but safe at runtime Somewhere challenging !
  • 12. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 12/49 Ripgrep (rg)Ripgrep (rg) An application written in RustAn application written in Rust A grep enhanced Compatible with standard grep Search speed is really impressive Look also at fd, exa, lsd...
  • 13. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 13/49 And a cute mascot !And a cute mascot !
  • 14. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 14/49 What it looks likeWhat it looks like extern crate flate2; use flate2::read::GzDecoder; use std::fs::File; use std::io::Read; fn run() -> String { let path = "ascii.txt.gz"; let mut contents = String::new(); let gz = File::open(path).unwrap(); // open and decompress file let mut uncompress = GzDecoder::new(gz); uncompress.read_to_string(&mut contents).unwrap(); contents // return implicitly contents } fn main() { println!("Hello, world!"); let result = run(); // call run function println!("{}", result); // display compress file content }
  • 15. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 15/49 Language featuresLanguage features Static type system with local type inference Explicit mutability Zero-cost abstractions Runtime-independent concurrency safety Errors are values No null Static automatic memory management No garbage collection
  • 16. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 16/49 Safety is achieved by mainly 3 conceptsSafety is achieved by mainly 3 concepts
  • 17. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 17/49 MutabilityMutability struct Bike { speed: u32, distance: u32, brand: String, } fn main() { let mybike = Bike { speed: 25, distance: 1508, brand: "Liteville".to_string(), }; mybike.speed = 30; //Reassign !!! println!( "Bike {}: speed={} distance={}", mybike.brand, mybike.speed, mybike.distance ); }
  • 18. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 18/49 Mutability errorMutability error error[E0594]: cannot assign to field `mybike.speed` of immutable binding --> src/main.rs:14:5 | 8 | let mybike = Bike { | ------ help: make this binding mutable: `mut mybike` ... 14 | mybike.speed = 30; //Reassign !!! | ^^^^^^^^^^^^^^^^^ cannot mutably borrow field of immutable binding error: aborting due to previous error For more information about this error, try `rustc --explain E0594`. error: Could not compile `immutability`.
  • 19. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 19/49 Ownership & BorrowingOwnership & Borrowing Every piece of data is uniquely owned Ownership can be passed When owned data reaches the end of a scope, it is destroyed
  • 20. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 20/49 OwnershipOwnership fn main() { let s1 = String::from("Hello, RUST ! 🦀"); let s2 = s1; println!("{}", s1); }
  • 21. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 21/49 Ownership errorOwnership error --> src/main.rs:3:9 | 3 | let s2 = s1; | = note: #[warn(unused_variables)] on by default error[E0382]: borrow of moved value: `s1` --> src/main.rs:4:20 | 3 | let s2 = s1; | -- value moved here 4 | println!("{}", s1); | ^^ value borrowed here after move | = note: move occurs because `s1` has type `std::string::String`, which does not implement the `Copy` trait error: aborting due to previous error For more information about this error, try `rustc --explain E0382`. error: Could not compile `owned2`.
  • 22. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 22/49 OwnershipOwnership fn main() { let s = String::from("Hello, RUST ! 🦀"); display(s); display(s); // Already owned ! } fn display(some_string: String) { println!("{}", some_string); }
  • 23. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 23/49 Ownership errorOwnership error error[E0382]: use of moved value: `s` --> src/main.rs:5:13 | 4 | display(s); | - value moved here 5 | display(s); // Already owned ! | ^ value used here after move | = note: move occurs because `s` has type `std::string::String`, which does not implement the `Copy` trait
  • 24. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 24/49 Ownership & BorrowingOwnership & Borrowing Access can be borrowed (mutable and immutable) You can borrow mutably once Or multiple times immutably Exclusive: mutable or immutable, never both
  • 25. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 25/49 BorrowingBorrowing fn main() { let s = String::from("Hello, RUST ! 🦀"); display(&s); display(&s); } fn display(some_string: &String) { println!("{}", some_string); } Hello, RUST ! 🦀 Hello, RUST ! 🦀
  • 26. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 26/49 Borrowing mutableBorrowing mutable fn main() { let s = String::from("Hello"); change(&s); println!("{}", s); } fn change(some_string: &String) { some_string.push_str(", RUST ! 🦀"); }
  • 27. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 27/49 Borrowing mutable errorBorrowing mutable error error[E0596]: cannot borrow immutable borrowed content `*some_string` as mutable --> src/main.rs:9:5 | 8 | fn change(some_string: &String) { | ------- use `&mut String` here to make mutable 9 | some_string.push_str(", RUST ! 🦀"); | ^^^^^^^^^^^ cannot borrow as mutable error: aborting due to previous error For more information about this error, try `rustc --explain E0596`. error: Could not compile `borrow_mut`.
  • 28. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 28/49 Borrowing mutable fixedBorrowing mutable fixed fn main() { let mut s = String::from("Hello"); change(&mut s); println!("{}", s); } fn change(some_string: &mut String) { some_string.push_str(", RUST ! 🦀"); } Hello, RUST ! 🦀
  • 29. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 29/49 References validity checksReferences validity checks #[derive(Debug)] struct Person<'a> { first_name: &'a str, last_name: &'a str, age: &'a i32, phone: Vec<&'a str>, } fn return_reference<'a>() -> Person<'a> { let age = 25; Person { first_name: "John", last_name: "Doe", age: &age, phone: vec!["123-123", "456-456"], } } fn main() { let person = return_reference(); println!("{:?}", person); }
  • 30. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 30/49 References validity checks errorReferences validity checks error error[E0597]: `age` does not live long enough --> src/main.rs:15:15 | 15 | age: &age, | ^^^ borrowed value does not live long enough ... 18 | } | - borrowed value only lives until here | note: borrowed value must be valid for the lifetime 'a as defined on the function body at 9:1... --> src/main.rs:9:1 | 9 | fn return_reference<'a>() -> Person<'a> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error For more information about this error, try `rustc --explain E0597`.
  • 31. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 31/49 Concurrency without fearConcurrency without fear
  • 32. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 32/49 Concurrency without fearConcurrency without fear
  • 33. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 33/49 Concurrency without fear errorConcurrency without fear error Rust type system allows no data racesRust type system allows no data races error[E0596]: cannot borrow `words` as mutable, as it is a captured variable in a `Fn` closure --> src/main.rs:19:54 | 19 | .for_each(|arg| tally_words(arg.to_string(), &mut words).unwrap()); | ^^^^^^^^^^ cannot borrow as mutable | help: consider changing this to accept closures that implement `FnMut` --> src/main.rs:19:19 | 19 | .for_each(|arg| tally_words(arg.to_string(), &mut words).unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error For more information about this error, try `rustc --explain E0596`.
  • 34. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 34/49 High level abstractionHigh level abstraction Generics and TraitsGenerics and Traits Define shared behavior Define behavior based on types Define behavior from various types with trait bounds
  • 35. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 35/49 Unsafe RustUnsafe Rust Allow to disengage some safety features Use at your own risk ! Crates using unsafe code can be audited with cargo- geiger
  • 36. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 36/49 A modern languageA modern language with builtin code quality standardswith builtin code quality standards Documentation embedded into code Unit tests Integration tests Great documentation (books and std lib)
  • 37. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 37/49 A modern languageA modern language with tools to be productivewith tools to be productive Environment setup and update rustup Package (crates) management cargo + plugin Code formatting rustfmt Compiler rustc Efficient error messages Potential solution Linter clippy Code completion racer Help transition to 2018 edition rustfix Editor integration (IntelliJ, Vs code, Vim, Emacs...)
  • 38. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 38/49 Opinionated for productivityOpinionated for productivity Avoiding bikesheddingAvoiding bikeshedding Crates have a defined filesystem structure Modules & exports based on file location (like Python) But with control over public / private exports (like ES6) Batteries included, but replaceable Procedural macros for DSLs (eg: JSON, CSS...) Custom compile-time extensions with build scripts Cargo extensions with cargo-foo binary crates
  • 39. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 39/49 Interesting cratesInteresting crates That extend the std libThat extend the std lib Date and time management chrono Parallel iteration rayon HTTP client reqwest Command line parsing clap, docopt, structopt Logging log Serialization serde Regular expressions regex ...
  • 40. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 40/49 Area of useArea of use Command line tools Web and network services Embedded device, IOT WebAssembly Games
  • 41. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 41/49 Who is using Rust ?Who is using Rust ? Mozilla, servo project RedHat, stratis project Dropbox Telenor Chef
  • 42. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 42/49 Who is using Rust ?Who is using Rust ? Ready at dawn Chucklefish that published Stardew Valley and Starbound, is using Rust in their new projects Wargroove and Witchbrook to get safe concurrency and portability
  • 43. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 43/49 Who is using Rust ?Who is using Rust ? Clevercloud, (Geoffroy Couprie) nom, parser Sozu, reverse proxy Snips ANSSI: RFC for secure application design in Rust
  • 44. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 44/49 Governance and communityGovernance and community Rust is pragmaticRust is pragmatic All features are driven by needs of real software The language is evolved with user feedback Consciously chooses familiar constructs Picks good ideas from others Doesn’t want to be the primary language at all cost
  • 45. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 45/49 Governance and communityGovernance and community Beloved language and communityBeloved language and community Voted "Most loved language" on Stackoverflow 2018, 2017, 2016 Only 1/100 of survey respondents have issues with the Rust community Newcomers from all directions https://insights.stackoverflow.com/survey/2018/#most-loved-dreaded-and-wantedhttps://insights.stackoverflow.com/survey/2018/#most-loved-dreaded-and-wanted
  • 46. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 46/49 Governance and communityGovernance and community growthgrowth https://8-p.info/visualizing-crates-io/https://8-p.info/visualizing-crates-io/ Crates.ioCrates.io
  • 47. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 47/49 Governance and communityGovernance and community Help from the communityHelp from the community Lots of books IRC and Discord channels User forum Youtube channel Meetups
  • 48. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 48/49 Governance and communityGovernance and community Beloved language and communityBeloved language and community Experience from Mozilla to drive open projects All major decisions, go to an open Request For Comments process Release every 6 weeks 3 channels: stable, beta and nightly Medium time to merged PR for changes: 6 days! More then 4/5 of contributions to the Rust language come from outside Mozilla The compiler has more then 2000 contributors
  • 49. 3/27/2019 Be pinched by a cRUSTacean to prevent programming errors ! localhost:8000/rust/?print-pdf#/ 49/49 THANK YOUTHANK YOU René Ribaud <[email protected]> François Best <[email protected]>