Rust’s approach of getting things right

Pascal Hertleif

2018-12-15

Hi, I’m Pascal Hertleif

[…] getting things right

– Pascal, writing presumptuous talk titles

What is Rust?

A systems programming language that runs blazingly fast, prevents segfaults, and guarantees thread safety.

What is Rust?

Empowering everyone to build reliable and efficient software.

What is Rust?

Technology from the past come to save the future from itself

– Graydon Hoare, inventor of Rust

confused travolta

Prior art

all information that has been made available to the public in any form before a given date that might be relevant to a patent’s claims of originality.

Wikipedia

We don’t need to re-invent everything

Embrace existing ideas and put them into our current context.

Not invented here

This is not a “Rewrite it in Rust” talk

It’s more of a “be curious and try out weird things” kind of talk

For example:
The borrow checker

Problem: Write memory-safe high-performance code

Prior art

Cyclone (2002)

  • “safe C”
  • never-NULL pointers
  • region analysis

ATS (2005)

  • ML-inspired language
  • built-in theorem prover

Prior art

Affine logic

Prior art

This work is about a functional language ΛLAΛ_{LA}, with a typable sub-set ΛLATΛ^{T}_{LA}. The types for ΛLATΛ^{T}_{LA} are polymorphic formulas of Intuitionistic Light Affine Logic […]

– Roversi, Luca. “Light affine logic as a programming language: a first contribution.” International Journal of Foundations of Computer Science 11.01 (2000): 113-152.

[…] Rust finally nailed it down in a way that is accessible to everyone.

– Stjepan Glavina

Adapting to the current context

Original borrowck doesn’t understand all valid programs

Non-lexical lifetimes

Borrow parts of a struct, self-references

Another example: ripgrep

super fast competitor to grep and ag

uses Rust’s regex crate

Prior art (regex)

  • Pike VM
  • Boyer-Moore & Aho-Corasick
  • Lazy DFA
  • Teddy

Adapting to the current context

  • Bringing it all together
  • Unicode support
  • Highly concurrent

Why sort() is like it is

I was reading the previous implementation of sort, just out of curiosity, and thought “wait, this could be done better”.

– Stjepan Glavina

Prior art

  • current impl
  • regular merge sort
  • blocksort
  • timsort

(See Rust PR #38192 for details)

Community

This was Stjepan’s first PR for Rust!

It took just three days to get into std!

He followed this up with a RFC to add sort_unstable

Where to find inspiration: Other ecosystems

crossbeam-channel

An improvement for the channels in std

Take inspiration from Go’s implementation

bounded/unbounded, MPMC, fancy select! macro

Other examples

Where to find inspiration: Academia

So many awesome engineering projects can be pulled off by just taking a quick glance at where current research is at in a particular field.

Often, implementations are lagging by several decades.

– Tyler Neely

Where to find interesting papers

Most of the things I read have no useful application for me right away. I need to let them simmer for a while.

– Geoffroy Couprie

Whenever something interesting comes out of academia, I try to think: How do we make this more practical? Can we reach a little bit farther? Can we bend the curve somewhere?

– Stjepan Glavina

“bend the curve”

The community is trying to find a way to overcome traditional trade-offs

incl. putting brand-new research into non-intimidating Rust-flavored packages!

Another tale: Green threads

  • Rust used green threads for async I/O
  • They were removed
  • Not the easy thing to do, but pays off in the long run

It’s okay to iterate on ideas

The first version might not be perfect

and that’s totally okay

I think of Rust as fertile ground for growing cool stuff.

– Stjepan Glavina

Do ambitious things!

  1. Be curious!
  2. Try to bend the curve!
  3. Help people discover awesome things!

Where to look for inspiration

  1. Other ecosystems
  2. Academia
  3. Completely different areas?

Thank you!

I’m Pascal and I want you to talk to me!

{twitter,github}.com/killercup

Slides: git.io/rust-approach