DEV Community

Cover image for The Rust
Taimoor khan
Taimoor khan

Posted on

The Rust

According to StackOverflow's Developer Survey Rust is most loved programming language for developers for past consecutive 5 years.

Rust is a statically typed programming language that promises Safety and Performance. It has modern yet hard to digest syntax and provides low level control (such as memory usage, pointers etc).
Rust is statically typed compiled language without anything like Garbage Collectors.

Question: How does Rust guarantee memory memory safety?
Answer: Rust manages memory through a system of Ownership with a set of rules that the compiler checks at compile time.

Hello World

Let's write our first program in Rust.

fn main(){
  println!("Hello World");
}
Enter fullscreen mode Exit fullscreen mode

User Input In Rust

Some types are not included in prelude so we need to explicitly call them into the scope by using use keyword. The std::io library provides number of useful features, including the ability to accept user input.

use std::io;

fn main(){
  println!("Your good name?:");

  let mut user_in = String::new();
  io::stdin()
      .readline(&mut user_in)
      .expect("something happened!");

  println!("Happy coding {}", user_in); 


}
Enter fullscreen mode Exit fullscreen mode

Do you think rust will dominate other statically typed languages?

Latest comments (0)