1 of 54

Systems

Programming

for Web

Developers

2 of 54

Herman J. Radtke III

VP of Engineering Nordstromrack.com|HauteLook

3 of 54

When It Matters

4 of 54

5 of 54

Rust:

  • Memory safety without GC
  • Concurrency without data races
  • Abstraction without overhead

6 of 54

arewewebyet .com?

7 of 54

Rust + Web Developer

=

Systems Programmer

8 of 54

9 of 54

Ruby Developers

Dev Ops

capistrano

puppet, chef

rvm, rbenv, chruby

Vagrant

Sensu

10 of 54

UI Developer

Full Stack Developer

Node

Node

Node

Node

11 of 54

Web Developer

Systems Programmer

12 of 54

Modern Web Stacks

Application Caching

HTTP Caching

Message/Job Queues

Relational, NoSQL, Search Databases

Load Balancers

VM / Containers

13 of 54

Knowledge

Gap

14 of 54

B

a

r

r

i

e

r

s

Web Developer

Memory Management

Thread Safety

Expressiveness

15 of 54

Why Rust?

  • Memory safety without GC
  • Concurrency without data races
  • Abstraction without overhead

16 of 54

Ownership

17 of 54

fn take(v: Vec<i32>) { }��let v = vec![1, 2, 3];��take(v);��println!("v[0] is: {}", v[0]);

18 of 54

error: use of moved value: `v`�println!("v[0] is: {}", v[0]);� ^

19 of 54

fn take(v: Vec<i32>) { }��let v = vec![1, 2, 3];��take(v);��println!("v[0] is: {}", v[0]);

20 of 54

Segmentations Faults

Use after free

Memory leaks

21 of 54

Compiler as

Teacher

22 of 54

with

confidence

Contribute Contribute Contribute Contribute

Contribute Contribute Contribute Contribute

Contribute Contribute Contribute Contribute

Contribute Contribute Contribute Contribute

23 of 54

Type Inference

24 of 54

let foo: i32 = 5;

25 of 54

let foo: i32 = 5;

let foo = 5;

26 of 54

let f = |x: i32| -> i32 { x };

27 of 54

let f = |x: i32| -> i32 { x };

let f = |x| { x };

28 of 54

fn silly<'a> (s: &'a str) -> &'a str { }

29 of 54

fn silly<'a> (s: &'a str) -> &'a str { }

fn silly (s: &str) -> &str { }

30 of 54

Optional

Correctness

31 of 54

let r = some_func();�if r.is_err() {� return false;�}��// happy path code

32 of 54

Option<T>

33 of 54

let foo = "bar";�let c = match foo.find('b') {� Some(c) => c,� None => panic!("Not found")�};

34 of 54

let foo = "nope";�let c = match foo.find('b') {� Some(c) => c,� None => panic!("Not found")�};

35 of 54

// yolo

let foo = "bar";let c = foo.find('b').unwrap();

36 of 54

Programmer Knows Best

37 of 54

let sparkle_heart = unsafe {� String::from_utf8_unchecked(� vec![240, 159, 146, 150]� );�};

38 of 54

Mullet Driven Dev

Ruby in the front

C in the back

Zero

Cost

Abstractions

39 of 54

let n = (1..10)� .map(|i| i * 2)� .filter(|&i| i > 5)� .fold(0, |acc, i| acc + i);

40 of 54

loop {� prompt()� .and_then(read)� .and_then(evaluate)� .and_then(print)� .unwrap_or_else( /* error */);�}

41 of 54

Generics

42 of 54

fn first<A, B>(pair: (A, B)) -> A {� let (a, _) = pair;� return a;�}

43 of 54

first((1, 2)); // returns 1�first(("a", "b")); // returns "a"

44 of 54

Monomorphization

45 of 54

first((1, 2)); // returns 1�first(("a", "b")); // returns "a"

46 of 54

fn first_i32(pair: (i32, i32)) -> i32 {� let (a, _) = pair;� return a;�}

47 of 54

fn first_str(pair: (&str, &str)) -> &str {� let (a, _) = pair;� return a;�}

48 of 54

fn first<A, B>(pair: (A, B)) -> A {� let (a, _) = pair;� return a;�}

49 of 54

Foreign Function

Interface

50 of 54

C

Lingua Franca

51 of 54

52 of 54

Rust LA Meetup

http://www.meetup.com/Rust-Los-Angeles/

53 of 54

Herman J. Radtke III

@hermanradtke

github.com/hjr3

hermanradtke.com/tags/rustlang.html

54 of 54

Questions?