A SAFE SYSTEM
PROGRAMMING LANGUAGE
AGENDA
 What is Rust ?
 History of Rust
 why would Mozilla sponsor rust
 Goals and features of the rust
 Rust package manager and commands
 Rust applications
 Example program for Rust
 advantages and disadvantages of the rust
WHAT IS RUST ?
 Rust is system programming language
sponsored by Mozilla Research. The design to
be a safe, concurrent, practical language.
Supporting Functional and imperative
procedural paradigms.
HISTORY OF RUST
 Started as a personal by graydon hoare from Mozilla some
time around 2008.
 Officially recognized as Mozilla sponsored project from 2009
and first announced in 2010.
 First pre-Alpha release in January 2012.
 Currently at 1.16 (stable).
 operating system support for Linux , windows , macOS ,
android , ios etc.
WHY WOULD MOZILLA SPONSOR RUST ?
 Want rust for next gen-infrastructure (service , iot).
 Servo is a next generation browser built in rust
GOALS OF RUST
Safety - statically typed with extensive compile time
validations.
The system in designed to be memory safe and it does
not permit null pointers , dangling pointer or data races in safe
code.
 SPEED: - Compiled , allows low level access similar to C/C++.
For main stream language , I know there different types of programs ,
architecture.
compilation:
Language is translated into MIR
and then compiled with LLVM
RUST MIR LLVM ASM
 CONCURRENT :-Built in support for threads , channels
There are two programing using Rust
1)Concurrent programming
2) Parallel programming
C/C++
Go
Java
Python
Haskell
RustControl
Safety
FEATURES OF RUST
 Zero – cost abstraction
 Algebraic data types (enum )
 Pattern matching
 Trait based generics
 Memory safety without garbage collection
Zero-cost abstractons (you pay only for what you use):-
A zero cost abstraction really means that abstraction
doesn’t impose a cost over the optimal implementation of
the task it is abstracting.
Algebric datatypes(enum):- enum means enumeration
data type consisting of a set of named values called
elements , member of the type.it does not use in c.
Pattern matching:-
patterns matching are quite common in
rust .
Ex:- let x=1;
match x {
1 => println! (“one”),
2 => println! (“two”),
3 => println! (“three”),
_ => println!(“anything”),
}
 Trait based generic :-
trait are like interfaces , combine traits for polymorphism
Rust package manager
 Cargo’s goal is to make modern application package management a core
value of the Rust programming language.
Some common cargo command are:
build compile the current project
doc build this project’s and its dependencies documentation
new create a new cargo project
run build and executes src/main.rs
test run the tests
bench run the benchmarks
update update dependencies listed in cargo . lock
search search registry for crates
publish package and upload this project to the registry
install install a rust binary
RUST APPLICATIONS
 Few applications written completely in rust:
 Servo
 Rocket
 Redox
 Habitat
WHAT TO DO WITH RUST
 System programming
 Web Browser (Mozilla Firefox)
 Distributed storage system (Dropbox)
 3d Games
 Operating system
 Device drive
 General tools
PROGRAM FOR RUST
#[deriving(show)]
enum Direction {
North,
East,
South,
West,
}
fn reverse(dir : Direction)->Direction {
match dir {
North => South,
East => West,
South => North,
West => East,
}
}
fn main() {
println!(“you should head: { }, reverse(North));
}
How to compile and run the RUST
program
Filename extensions:- .rs , .rlib
Compile program:-
C: user> rustc < filename >.rs
Run program:-
C: user> rust < filename >.rs
ADVANTAGES OF RUST
 Security is it’s biggest advantages
 Memory safety without garbage collection.
 High – performance.
 Provide awesome tools.
 Allow making mistakes.
DISADVANTAGES
 Large binary size
 Its almost impossible to run could be unsafe
 Consumes more memory
 Unlike many other languages, Rust doesn’t have
standard way of accessing database
CONCLUSION
 Rust is a promising System programming
language.
 Too young to use for fighting in the wild.
 Build enterprise class software with more
confident.
 Run at native speed (C/C+ comparable).
Rust

Rust

  • 1.
  • 2.
    AGENDA  What isRust ?  History of Rust  why would Mozilla sponsor rust  Goals and features of the rust  Rust package manager and commands  Rust applications  Example program for Rust  advantages and disadvantages of the rust
  • 3.
    WHAT IS RUST?  Rust is system programming language sponsored by Mozilla Research. The design to be a safe, concurrent, practical language. Supporting Functional and imperative procedural paradigms.
  • 4.
    HISTORY OF RUST Started as a personal by graydon hoare from Mozilla some time around 2008.  Officially recognized as Mozilla sponsored project from 2009 and first announced in 2010.  First pre-Alpha release in January 2012.  Currently at 1.16 (stable).  operating system support for Linux , windows , macOS , android , ios etc.
  • 5.
    WHY WOULD MOZILLASPONSOR RUST ?  Want rust for next gen-infrastructure (service , iot).  Servo is a next generation browser built in rust
  • 6.
    GOALS OF RUST Safety- statically typed with extensive compile time validations. The system in designed to be memory safe and it does not permit null pointers , dangling pointer or data races in safe code.
  • 7.
     SPEED: -Compiled , allows low level access similar to C/C++. For main stream language , I know there different types of programs , architecture. compilation: Language is translated into MIR and then compiled with LLVM RUST MIR LLVM ASM
  • 8.
     CONCURRENT :-Builtin support for threads , channels There are two programing using Rust 1)Concurrent programming 2) Parallel programming
  • 9.
  • 10.
    FEATURES OF RUST Zero – cost abstraction  Algebraic data types (enum )  Pattern matching  Trait based generics  Memory safety without garbage collection
  • 11.
    Zero-cost abstractons (youpay only for what you use):- A zero cost abstraction really means that abstraction doesn’t impose a cost over the optimal implementation of the task it is abstracting. Algebric datatypes(enum):- enum means enumeration data type consisting of a set of named values called elements , member of the type.it does not use in c.
  • 12.
    Pattern matching:- patterns matchingare quite common in rust . Ex:- let x=1; match x { 1 => println! (“one”), 2 => println! (“two”), 3 => println! (“three”), _ => println!(“anything”), }  Trait based generic :- trait are like interfaces , combine traits for polymorphism
  • 13.
    Rust package manager Cargo’s goal is to make modern application package management a core value of the Rust programming language. Some common cargo command are: build compile the current project doc build this project’s and its dependencies documentation new create a new cargo project run build and executes src/main.rs test run the tests bench run the benchmarks update update dependencies listed in cargo . lock search search registry for crates publish package and upload this project to the registry install install a rust binary
  • 14.
    RUST APPLICATIONS  Fewapplications written completely in rust:  Servo  Rocket  Redox  Habitat
  • 15.
    WHAT TO DOWITH RUST  System programming  Web Browser (Mozilla Firefox)  Distributed storage system (Dropbox)  3d Games  Operating system  Device drive  General tools
  • 16.
    PROGRAM FOR RUST #[deriving(show)] enumDirection { North, East, South, West, } fn reverse(dir : Direction)->Direction { match dir { North => South, East => West, South => North, West => East, } } fn main() { println!(“you should head: { }, reverse(North)); }
  • 17.
    How to compileand run the RUST program Filename extensions:- .rs , .rlib Compile program:- C: user> rustc < filename >.rs Run program:- C: user> rust < filename >.rs
  • 18.
    ADVANTAGES OF RUST Security is it’s biggest advantages  Memory safety without garbage collection.  High – performance.  Provide awesome tools.  Allow making mistakes.
  • 19.
    DISADVANTAGES  Large binarysize  Its almost impossible to run could be unsafe  Consumes more memory  Unlike many other languages, Rust doesn’t have standard way of accessing database
  • 20.
    CONCLUSION  Rust isa promising System programming language.  Too young to use for fighting in the wild.  Build enterprise class software with more confident.  Run at native speed (C/C+ comparable).