rustv2

18
RUST @nfmelendez Nicolás Meléndez

Upload: nicolas-melendez

Post on 18-Aug-2015

83 views

Category:

Engineering


1 download

TRANSCRIPT

Page 1: Rustv2

RUST

@nfmelendez

Nicolás Meléndez

Page 2: Rustv2

Mozilla sponsor since 2009

Using it for Servo. Mozilla’s browser engine in development.

Rust language v1.1

@nfmelendez

Page 3: Rustv2

RUST is systems programming language that combines low-level control with high-level convenience and safety guarantees.

Rust language v1.1

@nfmelendez

Page 4: Rustv2

Safety: prevent mutating, no aliasing, and no race conditions.

Control: over performance, deterministic destruction, no GC.

Convinience: Able to express your model.

Rust language v1.1

@nfmelendez

Page 5: Rustv2

Rust language v1.1

@nfmelendez

-Rust says: I give you control andSafety but if you follow somerules

Page 6: Rustv2

Rust language v1.1

@nfmelendez

-Rust says: I give you control andSafety but if you follow someRules-Dev: I accept your rules only ifyou tell me at compile time.

Page 7: Rustv2

Rust language v1.1

@nfmelendez

-Rust says: I give you control andSafety but if you follow someRules-Dev: I accept your rules only ifyou tell me at compile time. -Rust says: Ok. Deal.

Page 8: Rustv2

Rust language v1.1

@nfmelendez

You get this to break the rules. Very useful for…. (next talk).

Page 9: Rustv2

Rust language v1.1

@nfmelendez

1- Memory control & safety (no GC)

2- Data-race freedom (avoid concurrency bugs)

3- Lack of substantial runtime (easy to embed)

benefits

Enforcement of ownership and borrowing

Page 10: Rustv2

Rust language v1.1

@nfmelendez

Ownership

Example O01

Page 11: Rustv2

Rust language v1.1

@nfmelendez

Shared Borrow (&T)

Aliasing | mutable

Page 12: Rustv2

Rust language v1.1

@nfmelendez

Mutable Borrow (&mut)

Aliasing | mutable

Page 13: Rustv2

Rust language v1.1

@nfmelendez

1- You can borrow inmutable references many times (example B01)

2- You cannot borrow more than one mutable reference. Only one. example B012

3- Cannot exist a mutable reference and an inmutable one simultaneously

Borrowing rules

Page 14: Rustv2

Rust language v1.1

@nfmelendez

Data Race

Aliasing Mutation No ordening

Page 15: Rustv2

Rust language v1.1

@nfmelendez

Data Race

Aliasing (Actors) Mutation (Inmutation functional)

No ordening(Mutex)

Page 16: Rustv2

Rust language v1.1

@nfmelendez

ConcurrencyModel

Avoid Aliasing using ownership model only. (example C01)

Avoid mutation, using inmutable enforcement and Arc<T> references counters. (example C02)

Avoid no ordening, using mutex.

Page 17: Rustv2

Rust language v1.1

@nfmelendez

Tooling

Sublime text with rust package downloaded.

Cargo dependecy system + building

Debug. Only lldb? No UI or better?

Page 18: Rustv2

Rust language v1.1

@nfmelendez

GRACIAS

Examples in : https://github.com/nfmelendez/rust-talk-examples