Rust Sydney


I'm Huon Wilson, long-time Rust contributor: wrote a patch, got hooked... Somehow now organising a meetup.

Preliminaries – Thanks


Conduct of conduct, Summary:


Open source ( programming language. Originally a personal project of Graydon Hoare, adopted by Mozilla Research in 2009.

1.0.0-alpha released a month ago, full stable release soon!

Rust's Aims

A haiku:

a systems language
pursuing the trifecta
safe, concurrent, fast


"Systems language"

Control is critical, overhead minimal.

No garbage collection, no "runtime", use the OS directly where possible... write the OS too.

farcaller on /r/rust


Memory safety is a priority, avoid GC with powerful static analysis:

Compiler uses annotations on pointers (etc.) to ensure they're always valid.

Safe – lifetimes

fn get_ten<'a>(map: &'a HashMap<i32, String>) -> &'a String {
    let val = &map[10];



Rust provides tools to handle shared state and message passing safely, e.g.

No data races: locking/atomicity enforced when required.


Possible to implement a general parallel_map in safe code (in the near future: RFC 458), e.g. usable like:

// Eight integers on the stack
let mut stack_buffer = [0; 8];

// add one to each, in parallel
parallel_map(stack_buffer.iter_mut(), |item| {
    // item is a pointer into the main thread's stack
    *item += 1

println!("{:?}", &stack_buffer[]); // [1, 1, ..., 1];

Lifetimes, and the Send & Sync traits allow the compiler to guarantee safety.


Few runtime language features to stand in the way of the compiler. Standard libraries abstractions try to optimise well.

Benchmarks game, x86 one core


"Functional programming" iterators feel high-level:

pub fn sum(x: &[i32]) -> i32 {
    x.iter().fold(0, |a, b| a + *b)

Vectorised by LLVM! (16 i32s per iteration.)

    vpaddd  -48(%rdx), %xmm0, %xmm0
    vpaddd  -32(%rdx), %xmm1, %xmm1
    vpaddd  -16(%rdx), %xmm2, %xmm2
    vpaddd  (%rdx), %xmm3, %xmm3
    addq    $64, %rdx
    addq    $-16, %rdi
    jne .LBB0_4