I started learning Rust this week. I have just a few impressions ankle deep into the new (to me) language.

I’m using “The Rust Programming Language” book at doc.rust-lang.org. So far I’ve done enough to get it setup, configured a project to use Cargo, and finished the guessing-game tutorial.

use std::io;
use rand::Rng;
use std::cmp::Ordering;

fn main() {
    println!("Guess the number!");

    let secret_number = rand::thread_rng().gen_range(1, 101);

    loop {
        println!("Please input your guess.");

        let mut guess = String::new();
    
        io::stdin()
            .read_line(&mut guess)
            .expect("Failed to read line");
    
        let guess: u32 = match guess.trim()
            .parse() {
                Ok(num) => num,
                Err(_) => continue,
            };
    
        println!("You guessed: {}", guess);
    
        match guess.cmp(&secret_number) {
            Ordering::Less => println!("Too small!"),
            Ordering::Greater => println!("Too big!"),
            Ordering::Equal => {
                println!("You win!");
                break;
            }
        }
    }
}

I’m a Java & Nodejs developer by day.

It’s really easy to build and distribute binaries

The concept, as a Java and Nodejs, developer that has left the largest impression is the fact that Rust is an “ahead-of-time compiled” language. You compile your code using Rust’s compiler, rustc, then run your program like you would any other executable binary. This is mindblowing to me. Java is also an ahead-of-time compiled language, but you need an environment setup and installed on the host machine to execute code. Nodejs is compiled at runtime and you also need an environment setup on the host machine.

It has a package manager, Cargo

It’s a modern language that makes it really easy to manage your dependencies. Cargo has a similar feel as NPM.

It’s clean and minimal

I have done much more than what you see above, but I like what I see so far. It kinda has a functional programming feel to it with a dab of Kotlin and TypeScript.

Install Rust, get my hello-world source code, build and run it.

🧇