I believe in rust

2,513 views

Published on

  • Be the first to comment

I believe in rust

  1. 1. 54 2642" S 3 192" E I belive in Rust An intruduction to the Rust programming language1 22. august 2012 I belive in Rust JavaZone 2012 | 54 2642" S 3 192" E
  2. 2. Disclaimer • 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.2 22. august 2012 I belive in Rust JavaZone 2012 | 54 2642" S 3 192" E
  3. 3. So what is Rust • 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)3 22. august 2012 I belive in Rust JavaZone 2012 | 54 2642" S 3 192" E
  4. 4. Preparing for hello world • 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.html4 22. august 2012 I belive in Rust JavaZone 2012 | 54 2642" S 3 192" E
  5. 5. Simple hello world5 22. august 2012 I belive in Rust JavaZone 2012 | 54 2642" S 3 192" E
  6. 6. Tasks6 22. august 2012 I belive in Rust JavaZone 2012 | 54 2642" S 3 192" E
  7. 7. Task management • 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 GC7 22. august 2012 I belive in Rust JavaZone 2012 | 54 2642" S 3 192" E
  8. 8. Proper hello world8 22. august 2012 I belive in Rust JavaZone 2012 | 54 2642" S 3 192" E
  9. 9. Rust vs Java • 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 iteration9 22. august 2012 I belive in Rust JavaZone 2012 | 54 2642" S 3 192" E
  10. 10. High order functions10 22. august 2012 I belive in Rust JavaZone 2012 | 54 2642" S 3 192" E
  11. 11. Pattern matching11 22. august 2012 I belive in Rust JavaZone 2012 | 54 2642" S 3 192" E
  12. 12. Pattern matching example12 22. august 2012 I belive in Rust JavaZone 2012 | 54 2642" S 3 192" E
  13. 13. Ports and channels13 22. august 2012 I belive in Rust JavaZone 2012 | 54 2642" S 3 192" E
  14. 14. Ports and channels example14 22. august 2012 I belive in Rust JavaZone 2012 | 54 2642" S 3 192" E
  15. 15. Modules and crates15 22. august 2012 I belive in Rust JavaZone 2012 | 54 2642" S 3 192" E
  16. 16. Unit testing • Compiles with the --test flag and run • Not external lib but part of the compiler 16 22. august 2012 I belive in Rust JavaZone 2012 | 54 2642" S 3 192" E
  17. 17. The Servo Parallel Browser Project • Servo is a web browser engine written in the Rust language. It is currently developed on OS X and Linux. • https://github.com/mozilla/servo17 22. august 2012 I belive in Rust JavaZone 2012 | 54 2642" S 3 192" E
  18. 18. Yegge’s laundry list • 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.”18 22. august 2012 I belive in Rust JavaZone 2012 | 54 2642" S 3 192" E
  19. 19. The list for Go19 22. august 2012 I belive in Rust JavaZone 2012 | 54 2642" S 3 192" E

×