I believe in rust
-
Upload
reidar-sollid -
Category
Documents
-
view
1.970 -
download
2
Transcript of I believe in rust
![Page 1: I believe in rust](https://reader030.fdocuments.net/reader030/viewer/2022020110/55857219d8b42a472c8b4c5e/html5/thumbnails/1.jpg)
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
![Page 2: I believe in rust](https://reader030.fdocuments.net/reader030/viewer/2022020110/55857219d8b42a472c8b4c5e/html5/thumbnails/2.jpg)
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.
![Page 3: I believe in rust](https://reader030.fdocuments.net/reader030/viewer/2022020110/55857219d8b42a472c8b4c5e/html5/thumbnails/3.jpg)
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)
![Page 4: I believe in rust](https://reader030.fdocuments.net/reader030/viewer/2022020110/55857219d8b42a472c8b4c5e/html5/thumbnails/4.jpg)
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
![Page 5: I believe in rust](https://reader030.fdocuments.net/reader030/viewer/2022020110/55857219d8b42a472c8b4c5e/html5/thumbnails/5.jpg)
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
![Page 6: I believe in rust](https://reader030.fdocuments.net/reader030/viewer/2022020110/55857219d8b42a472c8b4c5e/html5/thumbnails/6.jpg)
6 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
Tasks
22. august 2012
![Page 7: I believe in rust](https://reader030.fdocuments.net/reader030/viewer/2022020110/55857219d8b42a472c8b4c5e/html5/thumbnails/7.jpg)
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
![Page 8: I believe in rust](https://reader030.fdocuments.net/reader030/viewer/2022020110/55857219d8b42a472c8b4c5e/html5/thumbnails/8.jpg)
Proper hello world
22. august 20128 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
![Page 9: I believe in rust](https://reader030.fdocuments.net/reader030/viewer/2022020110/55857219d8b42a472c8b4c5e/html5/thumbnails/9.jpg)
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
![Page 10: I believe in rust](https://reader030.fdocuments.net/reader030/viewer/2022020110/55857219d8b42a472c8b4c5e/html5/thumbnails/10.jpg)
10 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
High order functions
22. august 2012
![Page 11: I believe in rust](https://reader030.fdocuments.net/reader030/viewer/2022020110/55857219d8b42a472c8b4c5e/html5/thumbnails/11.jpg)
11 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
Pattern matching
22. august 2012
![Page 12: I believe in rust](https://reader030.fdocuments.net/reader030/viewer/2022020110/55857219d8b42a472c8b4c5e/html5/thumbnails/12.jpg)
12 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
Pattern matching example
22. august 2012
![Page 13: I believe in rust](https://reader030.fdocuments.net/reader030/viewer/2022020110/55857219d8b42a472c8b4c5e/html5/thumbnails/13.jpg)
13 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
Ports and channels
22. august 2012
![Page 14: I believe in rust](https://reader030.fdocuments.net/reader030/viewer/2022020110/55857219d8b42a472c8b4c5e/html5/thumbnails/14.jpg)
14 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
Ports and channels example
22. august 2012
![Page 15: I believe in rust](https://reader030.fdocuments.net/reader030/viewer/2022020110/55857219d8b42a472c8b4c5e/html5/thumbnails/15.jpg)
15 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
Modules and crates
22. august 2012
![Page 16: I believe in rust](https://reader030.fdocuments.net/reader030/viewer/2022020110/55857219d8b42a472c8b4c5e/html5/thumbnails/16.jpg)
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
![Page 17: I believe in rust](https://reader030.fdocuments.net/reader030/viewer/2022020110/55857219d8b42a472c8b4c5e/html5/thumbnails/17.jpg)
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
![Page 18: I believe in rust](https://reader030.fdocuments.net/reader030/viewer/2022020110/55857219d8b42a472c8b4c5e/html5/thumbnails/18.jpg)
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.”
![Page 19: I believe in rust](https://reader030.fdocuments.net/reader030/viewer/2022020110/55857219d8b42a472c8b4c5e/html5/thumbnails/19.jpg)
19 I belive in Rust JavaZone 2012 | 54°26'42" S 3°19'2" E
The list for Go
22. august 2012
![Page 20: I believe in rust](https://reader030.fdocuments.net/reader030/viewer/2022020110/55857219d8b42a472c8b4c5e/html5/thumbnails/20.jpg)