Rust is the new kid on the block. It's a system programming language that is blazingly fast and offers powerful high-level abstractions better known from dynamic languages like Ruby or Python. Rust offers memory safety without a Garbage Collector and makes low-level programming easier and more secure. I will give an introductory talk about Rust and show some of its nicest features.
2. - Düsseldorf, Germany
- Backend Engineer at trivago
- Website performance team
- Worked a lot with Python and PHP
- Likes hot chocolate
@matthiasendler
Matthias Endler
mre
11. Where Rust shines
Everywhere you want speed and safety
• Operating Systems
• Compilers
• Emulators
Encryption
• Databases
Numerics
• Graphics Programming
• Data Pipelines
Finance
• …
12. struct Person {
first_name: String,
last_name: String,
age: i32
}
impl Person {
pub fn new(first_name: String, last_name: String, age: i32) -> Person {
Person {
first_name: first_name,
last_name: last_name,
age: age
}
}
}
fn main() {
let mut vec = Vec::new();
vec.push(Person::new(String::from("Austin"), String::from("Powers"), 13));
vec.push(Person::new(String::from("Dr."), String::from("Evil"), 30));
for person in &vec {
let result = match person.age {
0...18 => "Teenager",
18 => "Old enough to go to war",
_ => "Too Old"
};
}
}
RUST
13. What I like about…
• PHP: Package manager, Community
• Python: Syntax, Libraries
• Golang:Tooling, Documentation, Concurrency
• C: Speed, no overhead
14. What I like about…
• PHP: Package manager, Community
• Python: Syntax, Libraries
• Golang:Tooling, Documentation, Concurrency
• C: Speed, no overhead
RUST
15. What sucks about…
• PHP: Syntax (a bit), legacy functions
• Python: Package manager, 2 vs 3
• Golang: Error handling, package
manager, no generics, Syntax (a bit)
• C: Missing package manager, safety
16. What sucks about
Rust
• Syntax (a bit)
• „Fighting with the Borrow checker“
• Missing packages (you can help!)
• probably more…
23. fn f(x: Type) {...}
fn f(x: &Type) {...}
fn f(x: &mut Type) {...}
Mutable borrow
Ownership
• Share as you like
• read-only
• one at a time
• read/write
Immutable borrow
• Total control
• read-write
28. Some common cargo commands are:
build Compile the current project
doc Build this project's and its dependencies' documentation
new Create a new cargo project
run Build and execute src/main.rs
test Run the tests
bench Run the benchmarks
update Update dependencies listed in Cargo.lock
search Search registry for crates
publish Package and upload this project to the registry
install Install a Rust binary
Cargo
the Rust package manager
29. Updating registry `https://github.com/rust-lang/crates.io-index`
simple_parallel (0.3.0) Straight-forward functions and types for basic data
parallel operations, including parallel maps, for loops and thread pools.
forkjoin (2.3.0) A work stealing fork-join parallelism library for Rust
arrayfire (3.2.0) ArrayFire is a high performance software library for
parallel computing with an easy-to-use API. Its array based function set m…
parry (0.1.0) Parallel array processing: deflect performance
problems.
mpi (0.2.0) Message Passing Interface bindings for Rust
specs (0.6.1) Parallel Entity-Component System. Specs is a parallel
ECS in Rust. It combines the performance of the beast with the flexibili…
collenchyma (0.0.8) high-performance computation on any hardware
substudy (0.4.0) Language-learning tools for working with parallel,
bilingual subtitles and media files.
crossbeam (0.2.9) Support for lock-free data structures, synchronizers,
and parallel programming
abc (0.2.3) An implementation of Karaboga's Artificial Bee Colony
algorithm.
... and 27 crates more (use --limit N to see more)
››› cargo search parallel
30. My tool wishlist
Unit testing: cargo test
Package manager
Syntax highlighting
Formatting
Code completion
Debugging
Code linter
Benchmarking
Profiling
Code coverage
45. We need to focus on those…
• Debugging
• Profiling
• Code Coverage
46. glium
• High-level wrapper around OpenGL
• Avoids all OpenGL errors
diesel • A safe, extensible ORM and Query Builder
• Operating System written in pure Rust,
designed to be modular and secure
Redox
crossbeam • A collection of lock-less data structures
turbine
• A high-performance, non-locking, inter-task
communication library written in Rust.
• Go channels on steroids
47. Bonus
rr - a reverse debugger
(http://rr-project.org/)
Dash - Offline API Documentation browser for Mac
(https://kapeli.com/dash)
Crates.io reverse package lookup
(https://crates.io/crates/serde/reverse_dependencies)