12 nov 2018 · APL / Lecture 16: The Rust Programming Language 2018-11-12 The final block of lectures covers some distinctive features of the Rust
Previous PDF | Next PDF |
[PDF] The Rust Programming Language - Lise Henrys page
Listings 10 - 17 · This chapter covers concepts that appear in almost every programming language and how they work in Rust Many programming languages
[PDF] The Rust Programming Language - AWS
Title: The Rust programming language / by Steve Klabnik and Carol Nichols ; with contributions Description: San Francisco : No Starch Press, Inc , 2018 Includes 9781593278519 (epub) ISBN 1593278519 (epub) ISBN 9781593278281 At first, you might even want to skip Chapter 3, which covers Rust features
[PDF] [Download] The Rust Programming Language (Covers Rust 2018
The Rust Programming Language (Covers Rust 2018) by Steve Klabnik, Read PDF The Rust Programming Language (Covers Rust 2018) Online, Download
[PDF] The Rust Programming Language Covers Rust 2018 By Steve Klabnik
LANGUAGE COVERS RUST 2018 2ND RUST PROGRAMMING BY EXAMPLE PDF FREE DOWNLOAD RUST PROGRAMMING LANGUAGE LEARN RUST
[PDF] the rust programming language
Listings 10 - 18 · Title: The Rust programming language / by Steve Klabnik and Carol Nichols ; Description: San Francisco : No Starch Press, Inc , 2018 Includes index Identifiers: LCCN 2018014097 (print) LCCN 2018019844 (ebook) ISBN able traits provided by the standard library, and Appendix D covers macros
[PDF] The Rust Programming Language - Blue Bus
Bookmark File PDF The Rust Programming Language The Rust Language ( Covers Rust 2018)Methods and Applications for Modeling and Simulation of
[PDF] The Rust Programming Language - A trial replacement for bloginf
12 nov 2018 · APL / Lecture 16: The Rust Programming Language 2018-11-12 The final block of lectures covers some distinctive features of the Rust
[PDF] the rust programming language book pdf
[PDF] the rust programming language klabnik pdf
[PDF] the rust programming language pdf download
[PDF] the rust programming language pdf free download
[PDF] the rust programming language pdf github
[PDF] the rust programming language pdf second edition
[PDF] the science behind acting
[PDF] the second world war: a complete history pdf
[PDF] the secret teachings of all ages audiobook
[PDF] the secret teachings of all ages manly palmer hall pdf
[PDF] the secret teachings of all ages summary
[PDF] the secret teachings of all ages wiki
[PDF] the set of non context free languages is closed under which of the following operations
[PDF] the set of strings of 0's and 1's whose number of 0's is divisible by five
https://wp.inf.ed.ac.uk/apl18 https://course.inf.ed.uk/aplAdvances in Programming Languages
Lecture 16: The Rust Programming Language
Ian Stark
School of Informatics
The University of Edinburgh
Monday 12 November 2018
Semester 1 Week 9
Outline
1Opening
2Rust Basics
3Very Slightly Beyond the Basics
4Closing
Ian Stark APL / Lecture 16: The Rust Programming Language 2018-11-12Outline
1Opening
2Rust Basics
3Very Slightly Beyond the Basics
4Closing
Ian Stark APL / Lecture 16: The Rust Programming Language 2018-11-12Topic: Programming for Memory Safety
The final block of lectures covers some distinctive features of theRust programming language.Introduction: Zero-Cost Abstractions (and their cost) Control of Memory: Deconstructed Objects, Ownership and BorrowingConcurrency: Shared Memory without Data Races
Rust is a fairly new language (1.0 in 2015) that aims to support safe and efficient systems programming. In support of that aim, much of its design builds on the kinds of advances in programming languages that have appeared in this course. Ian Stark APL / Lecture 16: The Rust Programming Language 2018-11-12Homework from Thursday
1. Do this
Watch these two short talks where Prof. Kathleen Fisher, first HACMS project leader, explains to project and its results: https://is.gd/hacms_ fisher and https://is.gd/hacms_ keynoteTo find out more about how the project went and what"s next read these two articles.https://is.gd/hacms_quadcopter
https://is.gd/hacms_helicopter https://is.gd/hacms_report2. Read thisKen Thompson
Reflections on Trusting Trust
Communications of the ACM, 27(8):761-763, 1984.
DOI: 10.1145/358198.358210
Ian Stark APL / Lecture 16: The Rust Programming Language 2018-11-12Outline
1Opening
2Rust Basics
3Very Slightly Beyond the Basics
4Closing
Ian Stark APL / Lecture 16: The Rust Programming Language 2018-11-12The Rust Programming Language
TheRustlanguage is intended as a tool forsafe systems programming. Three key objectives contribute to this.Zero-cost abstractionsMemory safety
Safe concurrencyBasic References
https://www.rust-lang.orghttps://blog.rust-lang.orgThe "systems programming" motivation resonates with that for imperativeC/C++ . The "safe"
draws extensively on techniques developed for functionalHask ell
and OCaml . Sometimes thesealign more closely than you might expect, often through overlap between two aims:Precise control for the programmer;
Precise information for the compiler.
Ian Stark APL / Lecture 16: The Rust Programming Language 2018-11-12Rust: When and How
Rust originated in 2006, took off with sponsorship fromMozilla
in 2009, and reached its firststable release with Rust 1.0 in May 2015.Mozilla use it for their experimentalServo concurrent HTML la youtengine, and some pa rtsof
Firefox
.Dropbox rewrote their backend file system in Rust, to support the move off Amazon WebServices to their own storage infrastructure.The "Friends of Rust" list identifies a number of organizations using Rust in production.
This year"s Stack Overflow developer survey awarded Rust:Most Loved Language of The Year 2018...following its previous ranking as Most Loved Language of The Year 2016 and Most Loved
Language of The Year 2017.
Ian Stark APL / Lecture 16: The Rust Programming Language 2018-11-12Variables that Don"t
Bindings
let x = 10; let y = true; let (a,b,c) = (7,8,56); x = x+1; // Error: bindings immutable by default let mut z = a?b;z = c+c+c; // OK: z declared as mutableBy default all "variables" are immutable. Everything here is statically typed: sox : i32 and
y : bool , but all is inferred. Ian Stark APL / Lecture 16: The Rust Programming Language 2018-11-12Functions and Expressions
Function declaration
fn abs (x:i32) -> i32 { if x > 0 { x } else { -x } }Functiona bsmust decla rethe t ypeof its a rgument,and it lo oksa litt lelik eC as w ege tto use braces (curly brackets) a lot. Everything else, though...Strict static typingType inference
Binding
x is immutableThe body
if is an exp ression,not a statementSo are its branches
x and - xFunction abs
is itself a value, of t ype fn(i32) - >i32 Ian Stark APL / Lecture 16: The Rust Programming Language 2018-11-12Control flow
Assorted looping
loop { println!("Around we go"); while b { // At this point we definitely need code; // some mutable state and imperative } // programming with side-effects. for c in 1..5 { println!( "Now c is {}", c ); // Will print 1, 2, 3, 4 Ian Stark APL / Lecture 16: The Rust Programming Language 2018-11-12Control flow
Where Rust is not C
for (c = 1; c < 15; c++) { printf( "Now c is %d\n", c ); }Rust does not provide the generalfo rlo opof C, intentionally .All of
lo op while fo r a re"zero-cost", in that th eycan readily b ecompiled in the simplest w ay possible and exactly as you would expect. They also have the advantage of abstraction:Enables the programmer to do more;Enables the compiler to do more.
There is still a cost, though, in the constraint on the programmer. Ian Stark APL / Lecture 16: The Rust Programming Language 2018-11-12Structured Values
Tuples
let v = (2, true, -3.0); let w = v; let a = w.1; let b = w.2; let (x,y,z) = w; Ian Stark APL / Lecture 16: The Rust Programming Language 2018-11-12Outline
1Opening
2Rust Basics
3Very Slightly Beyond the Basics
4Closing
Ian Stark APL / Lecture 16: The Rust Programming Language 2018-11-12Structured Values
Structs
struct Point { x: f64, y: f64, let p = Point { x: 1.0, y: -2.5 }; let (a,b) = p; let mut q = Point { x: 0.0, y: 0.0 }; q.x = q.x + 3.4; Ian Stark APL / Lecture 16: The Rust Programming Language 2018-11-12Structured Values
Tuple Structs
struct ThreePoint(i32,i32,i32); struct Date(i32,i32,i32); let xunit = ThreePoint(1,0,0); // These two values let today = Date(2016,11,15); // have different types struct Inches(f64); let height = Inches(43.2); // height: Inches let Inches(h) = height; // h: f64 Ian Stark APL / Lecture 16: The Rust Programming Language 2018-11-12Enumerations
Declaring enumerations
enum Draw {MoveTo { x: i32, y: i32 },
PenUp,
PenDown { r: i32, g: i32, b: i32},
Quit, let up = Draw::PenUp; let start = Draw::PenDown{ r:255, g:255, b:255 }; Ian Stark APL / Lecture 16: The Rust Programming Language 2018-11-12Enumerations
Using enumerations
match b { true => println!("It?s true!"), false => println!("It?s not true!"), match drawcommand {PenUp => println!("Raise pen"),
PenDown { r, g, b } => println!("Red {} Green {} Blue {}",r,g,b),MoveTo { x, y } => println!("On the move"),
Quite => println!("All done"),
Ian Stark APL / Lecture 16: The Rust Programming Language 2018-11-12Generics
Declaring a Parameterised Type
enum OptionSome(T),
None, }Using a Parameterised Type let x: OptionGenerics
Parametric Polymorphism
fn testSome(x) => true,
None => false,
fn exchangeOutline
1Opening
2Rust Basics
3Very Slightly Beyond the Basics
4Closing
Ian Stark APL / Lecture 16: The Rust Programming Language 2018-11-12Review
Some basic Rust constructions.Rustbindingslikelet x = 10; a reimmutable b ydefault. Mutability must be explicitly declaredlet mut y = true;
Rust has conditionals, loops, and first-class functions.Values can be arranged intuples,structs,tuple structsand labelledenumerations.Values can be decomposed with pattern matching and a discriminatingmatch statement.
Parametric polymorphism is available through generic structs, enumerations, and functions. Ian Stark APL / Lecture 16: The Rust Programming Language 2018-11-12