rust and python code example

Example 1: rust vs python

If you just want to learn programming, first learn python then rust.

Rust is:
=> systems programming language without a garbage collector focused on three goals: safety, speed, and concurrency
=> Faster than python
=> Compiled directly to machine code
=> Similar to Go and C
=> Has better thread and memory managment
Why should you use it:
  -> You need speed.
  -> You want to do something low level

+---------------------------------------------------+

Python is:
=> multi-paradigm, dynamically typed, multipurpose programming language.
=> easy to learn
=> interpeted
Why should you use it:
  -> When you want simplicity
  -> When you are doing something general purpose
  -> When you dont care about speed
  -> readability

+---------------------------------------------------+

Python:
var = 0
print(var)
var += 1
print(var)

Rust:
fn main() {
    let mut var = 0;
    println!("{}", var);
    var += 1;
    println!("{}", var);
}

Example 2: rust vs python

//hello world in rust
fn main {
	println!("hello world);
}

#hello world in python
print("Hello World")

Tags:

Misc Example