i believe in rust
TRANSCRIPT
1 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
I belive in RustAn intruduction to the Rust programming language
54°26'42" S 3°19'2" E
22. august 2012
2 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
Disclaimer
22. august 2012
• I am an Rust newbie• Rust is in 0.31 and have probably
changed since I wrote these slides. Example code might not compile with the latest and greatest.
3 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
So what is Rust
22. august 2012
• A programming language from Mozilla labs
• Compiled un-managed language• Ahead of time compiler• Concurrent-oriented– Message passing– Default immutable variables (mutable keyword)
• Lambda expressions with a lot if easy to use code
• Classes and traits• No NPE crashes, libs use Option<T> or
Result<T,U>• Unsigned types (Singed byte is a bad
idea)
4 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
Preparing for hello world
22. august 2012
• Git clone and build from source– Dependencies
• G++ 4.4 or above or clang++3.x• Python 2.6 or later• Gnu make 3.8.1 or later• curl
• Download binaries• Emacs and Eclipse plugins• http://dl.rust-lang.org/doc/
tutorial.html
5 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E 22. august 2012
Simple hello world
22. august 20125 I belive in Rust JavaZone 2012
6 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
Tasks
22. august 2012
7 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
Task management
22. august 2012
• An Rust program consists of a tree of tasks, with their own stack and sole ownership of allocated heap data
• Communicate through ports and channels
• Propagates failures to its parent (the task spawned this one) unless unsupervise function is called.
• May be executed in parallel and are scheduled by the runtime
• Has its own GC
Proper hello world
22. august 20128 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
9 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
Rust vs Java
22. august 2012
• Java has global GC Rust has per-task GC
• Rust does not share memory but communicate through message passing
• Rust is compiled to native AOT compiler
• Rust is per default immutable– Use the keyword mut to create mutable
• Rust has unsigned types• No null pointer crashes• High order functions for iteration
10 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
High order functions
22. august 2012
11 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
Pattern matching
22. august 2012
12 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
Pattern matching example
22. august 2012
13 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
Ports and channels
22. august 2012
14 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
Ports and channels example
22. august 2012
15 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
Modules and crates
22. august 2012
16 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
Unit testing
22. august 2012
• Compiles with the --test flag and run
• Not external lib but part of the compiler
17 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
The Servo Parallel Browser Project
22. august 2012
• Servo is a web browser engine written in the Rust language. It is currently developed on OS X and Linux.
• https://github.com/mozilla/servo
18 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
Yegge’s laundry list
22. august 2012
• Dave Cheneys blog post on Go – “While languages like Julia or Rust
approach 100% coverage of Yegge’s laundry list, it is still to be seen if they will achieve mainstream adoption.”
19 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
The list for Go
22. august 2012