A Brief History of Rust
Hey, there's a local Rust meetup
in the Triangle area!
Check them out!
meetup.com/triangle-rustaceans/
A Brief History of Rust
circa 2006: Rough inception
2009: Tentative Mozilla involvement
2010: Public Mozilla commitment
2011: Compiler self-hosts, Servo begins
2012: First public release
2014: First beta release
2015: First stable release
Timeline
2006-2009
~foo(lit,er,als) {
... a-random-string ...
}
User-defined literals
2006-2009
try {
...
} trap foo(x) {
fix x + 10;
} trap bar(y) {
log "got a bar";
fail;
}
Exceptions
2006-2009
if (... ) {
x = foo();
} else {
// "uh oh"
x = raise foo(gurgle);
}
Exceptions
2006-2009
fn f(int x, int y) -> () { ... }
type thunk1 = fn f(int x) -> ();
type thunk0 = fn f() -> ();
let thunk1 t1 = bind f(10,_);
let thunk1 t2 = bind f(_,10);
let thunk0 t0 = bind f(10,12);
No closures, only currying
2006-2009
// what
for (~auto e = v.(,)) {
out <| e <| endl;
}
Iterators and printing
2006-2009
Language runtime
"Hmm. I am generally not interested in multithreading: it's not worth the pain. There are reasons you might want it, but they're few."
2006-2009
Tuples
"NO DAMN TUPLES" [...] "NO WAIT, WE NEED TUPLES"
2006-2009
References
"Can you alias a non-copyable? Hmm. There is very little point! You would not be able to copy an alias-of-a-non-copyable and, as it's an alias, you would not be able to move (modify) it either."
2006-2009
type mt = mod {
type e;
fn mk()->e;
fn eat(e)->nil;
}
let mt mv = mod {
type e = int;
fn mk()->e { ret 1; }
fn eat(int i) { }
}
use mt mm = mv;
let mm.e me = mm.mk();
mm.eat(me);
First-class modules
2006-2009
let set[int] s1 = listSet[int];
let set[int] s2 = treeSet[int];
let set[int] s3 = mod set[int] {
type t = []; ...
}
Square brackets
2006-2009
Typestate
"Every program containing symbolic expressions maps to a sequence of statements in a 3-operand-statement normal form with call-by-value-return move-semantics on slots and bindings. Every "point" (inbetween normalized statements) in a program has a typestate. Two typestates are therefore defined for each statement: its prestate and its poststate. A typestate is formally a set of N-ary boolean predicates over visible slots. Typestates form a semilattice ordered by subset-inclusion (x < y means x is a subset of y), where 'join' means 'set intersection'. When N statements lead to a single point, the point's typestate is the pairwise join of the N poststates of preCeding statements."
2011
category name(T) {
fn foo(params) -> ret {
/* self has type &T */
}
priv fn bar(params) -> ret {
/* self has type &T */
}
}
"Categories"
2011
struct T<...> {
member1: T1;
mutable member2: T2;
priv member3: T3;
}
"Categories"
2011
iface animal {
fn speak();
fn play();
};
Interfaces
2012
class monster {
let mut health: int;
let name: str;
new(health: int, name: str) {
self.health = health;
self.name = name;
}
}
Classes
2012
use std;
fn main(args: [str]) {
std::io::println("hello from '"
+ args[0]
+ "', world!");
}
Hello World
2012
#warn("only %d seconds remaining", 10);
#error("fatal: %s", get_err_string());
Macros
2012
fn call_twice(f: block()) { f(); f(); }
call_twice({|| "I am a block"; });
call_twice(fn@() { "Boxed closure"; });
fn bare_function() { "Plain function"; }
call_twice(bare_function);
Closures
2012
alt mypoint {
{x: 0f, y: y_name} { /* Sub-pattern */ }
{x, y} { /* Bind */ }
}
Matching
2012
let x = @10; // New box, refcount of 1
let y = x; // Copy pointer, bump refcount
Garbage-collected data
2012
let x = ~10;
let y <- x;
Owned data
A Brief History of Rust
By bstrie
A Brief History of Rust
- 5,632