Introductie Rust voor Linux User Group Nijmegen 14 juni 2022
Bèr berkes
Kessels
berkes
KesselsSoftware is eating the world
– Marc Andreessen
De wereld, anno 2022, draait op C.
I call it my billion-dollar mistake…
– Tony Hoare, inventor of ALGOL W.
Roughly 70% of all serious security bugs in the Chrome codebase are memory management and safety bugs
– Google engineers
Rust is intended to be a language for highly concurrent and highly safe systems,
– Graydon Hoare inventor of Rust.
Op te lossen probleem: Memory Safety
String greeting = "Hello";
Rust Is the Industry’s ‘Best Chance’ at Safe Systems Programming – Microsoft
Ownership is Rust’s most unique feature, and it enables Rust to make memory safety guarantees without needing a garbage collector. – The Rust Handbook
By leveraging ownership and type checking, many concurrency errors are compile-time errors in Rust rather than runtime errors. – The Rust Programming Lanuage Handbook
Android, Amazon, Cloudflare, Discord, Dropbox, …
Microsoft, Google, IBM, Facebook, Huawei, Mozilla, Samsung, Kraken.
Signal, System76, Npm, Nextcloud, Fly.io.
Result<T,E>
, Types, Traits, etc.: Decennia aan OOP uitbannen.rustc hello.rs
fn main() {
let name = format!("{} {}", "Bèr", "Kessels");
greet(name);
greet(42);
}
fn greet(name: String) {
println!("Hello {}!", name);
}
fn main() {
let name = format!("{} {}", "Bèr", "Kessels");
greet(name);
println!("Goodbye, {}", name);
}
fn greet(name: String) {
println!("Hello {}!", name);
}
pub trait Summary {
fn summarize(&self) -> String;
}
pub struct NewsArticle {
pub headline: String,
pub location: String,
pub author: String,
pub content: String,
}
impl Summary for NewsArticle {
fn summarize(&self) -> String {
format!("{}, by {} ({})", self.headline, self.author, self.location)
}
}
pub struct Tweet {
pub username: String,
pub content: String,
pub reply: bool,
pub retweet: bool,
}
impl Summary for Tweet {
fn summarize(&self) -> String {
format!("{}: {}", self.username, self.content)
}
}
pub fn notify<T: Summary>(item: &T) {
println!("Breaking news! {}", item.summarize());
}
apt-get install rustc rust-all
)apt-get install cargo
)Udemy, Coursera, Freecodecamp