Slide 1

Slide 1 text

Why Rust?

Slide 2

Slide 2 text

- Düsseldorf, Germany - Backend Engineer at trivago - Website performance team - Worked a lot with Python and PHP - Likes hot chocolate @matthiasendler Matthias Endler

Slide 3

Slide 3 text

Rust - Created by Graydon Hoare - Funded by Mozilla - Primary goal: A safer systems language - First version: 2010 - Current stable version 1.8

Slide 4

Slide 4 text

System Programming Memory management Error handling Static Typing Compiling …

Slide 5

Slide 5 text

System Programming is challenging!

Slide 6

Slide 6 text

• Provide the right abstractions • Provide awesome tools • Allow making mistakes • Build a helpful community System Programming can be fun!

Slide 7

Slide 7 text

RUST: High level on bare metal

Slide 8

Slide 8 text

Where Rust makes sense Everywhere you want speed and safety • Operating Systems • Compilers • Emulators
 Encryption • Databases
 Numerics • Graphics Programming • Data Pipelines
 Finance • …

Slide 9

Slide 9 text

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

Slide 10

Slide 10 text

Type safety Type expression Type checking Garbage Collector C unsafe explicit static No C++ unsafe explicit static No Go safe implicit/explicit static Yes Rust safe implicit/explicit static/dynamic optional

Slide 11

Slide 11 text

#include #include #include int main() { std::vector v; v.push_back("foo"); auto const &x = v[0]; v.push_back("bar"); // Undefined behavior! std::cout << x; } C++

Slide 12

Slide 12 text

fn main() { let mut v = Vec::new(); v.push("foo"); let mut x = &mut v[0]; v.push("bar"); println!("{}", x) } RUST

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

What I like about… • PHP: Package manager, Community • Python: Syntax, Libraries • Golang: Tooling, Documentation, Concurrency • C: Speed, no overhead

Slide 15

Slide 15 text

What I like about… • PHP: Package manager, Community • Python: Syntax, Libraries • Golang: Tooling, Documentation, Concurrency • C: Speed, no overhead RUST

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

What sucks about Rust • Syntax (a bit) • „Fighting with the Borrow checker“ • Missing packages (you can help!) • probably more…

Slide 18

Slide 18 text

Complexity vs Speed • PHP • Python • Golang • Rust • C Faster „Easier“

Slide 19

Slide 19 text

IDEs?

Slide 20

Slide 20 text

Visual Studio

Slide 21

Slide 21 text

Visual Studio Code using Rusty Code plugin

Slide 22

Slide 22 text

Atom with language-rust plugin

Slide 23

Slide 23 text

My tool wishlist Unit testing: builtin Package manager Syntax highlighting Formatting Code completion Debugging Code linter Benchmarking Profiling Code coverage

Slide 24

Slide 24 text

https://doc.rust-lang.org/book/testing.html Unit testing

Slide 25

Slide 25 text

My tool wishlist Unit testing: builtin Package manager: cargo Syntax highlighting Formatting Code completion Debugging Code linter Benchmarking Profiling Code coverage

Slide 26

Slide 26 text

My tool wishlist Unit testing: builtin Package manager: cargo Syntax highlighting: atom-language-rust Formatting Code completion Debugging Code linter Benchmarking Profiling Code coverage

Slide 27

Slide 27 text

My tool wishlist Unit testing: builtin Package manager: cargo Syntax highlighting: atom-language-rust Formatting: rustfmt Code completion Debugging Code linter Benchmarking Profiling Code coverage

Slide 28

Slide 28 text

My tool wishlist Unit testing: builtin Package manager: cargo Syntax highlighting: atom-language-rust Formatting: rustfmt Code completion: racer Debugging Code linter Benchmarking Profiling Code coverage

Slide 29

Slide 29 text

My tool wishlist Unit testing: builtin Package manager: cargo Syntax highlighting: atom-language-rust Formatting: rustfmt Code completion: racer Debugging: rust gdb? Code linter Benchmarking Profiling Code coverage

Slide 30

Slide 30 text

My tool wishlist Unit testing: builtin Package manager: cargo Syntax highlighting: atom-language-rust Formatting: rustfmt Code completion: racer Debugging: rust gdb? Code linter: clippy Benchmarking Profiling Code coverage

Slide 31

Slide 31 text

My tool wishlist Unit testing: builtin Package manager: cargo Syntax highlighting: atom-language-rust Formatting: rustfmt Code completion: racer Debugging: rust gdb? Code linter: clippy Benchmarking: builtin Profiling Code coverage

Slide 32

Slide 32 text

My tool wishlist Unit testing: builtin Package manager: cargo Syntax highlighting: atom-language-rust Formatting: rustfmt Code completion: racer Debugging: rust gdb? Code linter: clippy Benchmarking: builtin Profiling: meh… Code coverage

Slide 33

Slide 33 text

My tool wishlist Unit testing: builtin Package manager: cargo Syntax highlighting: atom-language-rust Formatting: rustfmt Code completion: racer Debugging: rust gdb? Code linter: clippy Benchmarking: builtin Profiling: meh… torch? Code coverage

Slide 34

Slide 34 text

https://llogiq.github.io/2015/07/15/profiling.html Calls Time

Slide 35

Slide 35 text

My tool wishlist Unit testing: builtin Package manager: cargo Syntax highlighting: atom-language-rust Formatting: rustfmt Code completion: racer Debugging: rust gdb? Code linter: clippy Benchmarking: builtin Profiling: meh… torch? Code coverage: kcov?

Slide 36

Slide 36 text

kcov …is a code coverage tester for compiled programs, Python scripts and shell scripts language: rust matrix: fast_finish: true include: - rust: nightly env: FEATURES="--features nightly" sudo: false - rust: nightly env: FEATURES="--features nightly" BENCH=true sudo: false - rust: beta sudo: true after_success: | sudo apt-get install libcurl4-openssl-dev libelf-dev libdw-dev && wget https://github.com/SimonKagstrom/kcov/archive/master.tar.gz && tar xzf master.tar.gz && mkdir kcov-master/build && cd kcov-master/build && cmake .. && make && sudo make install && cd ../.. && kcov --coveralls-id=$TRAVIS_JOB_ID --exclude-pattern=/.cargo target/kcov target/debug/hyper-* Put this into your .travis.yml:

Slide 37

Slide 37 text

Summary Lots of work to do But impressive start

Slide 38

Slide 38 text

We need to focus on those… • Debugging • Profiling • Code Coverage

Slide 39

Slide 39 text

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

Slide 40

Slide 40 text

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)

Slide 41

Slide 41 text

www.meetup.com/Rust-Amsterdam

Slide 42

Slide 42 text

Even more at https://gist.github.com/nrc/a3bbf6dd1b14ce57f18c http://kukuruku.co/hub/rust/comparing-rust-and-cpp