DEV Community

Cover image for RUST:MY JOURNEY FROM 0 TO 1(Day 1)
Jesee Jackson Kuya
Jesee Jackson Kuya

Posted on

RUST:MY JOURNEY FROM 0 TO 1(Day 1)

You’ve probably heard the rumors and hype surrounding Rust.

The language that does everything.
The language developers fear.
The language AI supposedly struggles with.
The language companies are rewriting their entire codebases in.

And so on...

typical

But how much of this is actually true?

This series is my journey to debunk the rumors. I want to see for myself what Rust is really about.

The goal is simple:

Learn Rust and ship a real product to production.

And I’ll track how many days it actually takes.

I’m a firm believer in learning the hard way, so instead of watching 50 tutorials on YouTube, I’ll be using the official Rust documentation:

The Rust Book

https://doc.rust-lang.org/book/


Installation

Installing Rust is surprisingly easy.

I’m using Manjaro Linux, which is Arch-based. On most Linux distributions, you can install Rust with a single command.

Open your terminal and run:

curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh
Enter fullscreen mode Exit fullscreen mode

This installs Rust using rustup, the official installer and version manager.

Honestly, this might be one of the smoothest language installations I’ve ever done.


Important Note

There’s one thing that can cause installation errors.

Rust requires a C compiler during installation.

If you don't already have one installed, install gcc first.

On Arch / Manjaro:

sudo pacman -S base-devel
Enter fullscreen mode Exit fullscreen mode

If the installation command fails, you can follow the official guide here:

https://doc.rust-lang.org/book/ch01-01-installation.html


Jumping Right Into Rust

The first example in the Rust book is a number guessing game.

Here’s the full code:

use std::cmp::Ordering;
use std::io;

use rand::Rng;

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

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

    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;
            }
        }
    }
}
Enter fullscreen mode Exit fullscreen mode

If you're new to Rust, this code might look a little unusual at first.

But surprisingly, it becomes readable pretty quickly.

Let’s break it down.


Understanding use

The first thing you notice is the code starting with:

use std::cmp::Ordering;
use std::io;
use rand::Rng;
Enter fullscreen mode Exit fullscreen mode

The use keyword is essentially Rust’s import system.

It tells the compiler which functionality from other modules we want to use.

Think of it like:

Language Import syntax
Python import random
JavaScript import fs from "fs"
Rust use rand::Rng

For example:

use std::io;
Enter fullscreen mode Exit fullscreen mode

This imports Rust’s input/output library so we can read input from the terminal.

And this line:

use rand::Rng;
Enter fullscreen mode Exit fullscreen mode

imports a trait that allows us to generate random numbers.


Generating the Secret Number

This line creates the number the user must guess:

let secret_number = rand::thread_rng().gen_range(1..=100);
Enter fullscreen mode Exit fullscreen mode

What’s happening here?

  1. thread_rng() creates a random number generator.
  2. gen_range(1..=100) generates a number between 1 and 100.

So every time the game runs, a new number is generated.


Variables in Rust

This line creates a variable:

let mut guess = String::new();
Enter fullscreen mode Exit fullscreen mode

Two important things are happening here.

let

let declares a variable.

mut

Rust variables are immutable by default.

That means their value cannot change unless you explicitly say they can.

Example:

let x = 5;
Enter fullscreen mode Exit fullscreen mode

This value cannot be changed.

But this can:

let mut x = 5;
x = 6;
Enter fullscreen mode Exit fullscreen mode

Rust forces you to be explicit about mutation, which helps prevent bugs.


Reading User Input

This section reads input from the terminal:

io::stdin()
    .read_line(&mut guess)
    .expect("Failed to read line");
Enter fullscreen mode Exit fullscreen mode

What this does:

  1. Waits for user input
  2. Stores it in the guess variable
  3. Crashes with a helpful message if something fails

Rust prefers explicit error handling, which you’ll see a lot.


Pattern Matching

One of Rust’s most powerful features is pattern matching.

This block converts the input into a number:

let guess: u32 = match guess.trim().parse() {
    Ok(num) => num,
    Err(_) => continue,
};
Enter fullscreen mode Exit fullscreen mode

Here’s what’s happening:

  • The program tries to convert the input into a number.
  • If it succeeds → use the number.
  • If it fails → ignore it and ask again.

This avoids crashes if the user types something like:

hello
Enter fullscreen mode Exit fullscreen mode

Instead of breaking the program, Rust simply loops again.


Comparing the Guess

Now we compare the guess with the secret number.

match guess.cmp(&secret_number) {
Enter fullscreen mode Exit fullscreen mode

Rust compares the values and returns:

  • Less
  • Greater
  • Equal

Then we print the appropriate message.


What I Learned on Day 1

After writing this small program, a few things became clear.

Rust is strict

Rust forces you to write safe code.

This can feel annoying at first, but it prevents many bugs.


Rust is very explicit

Nothing happens magically.

You must clearly state:

  • variable types
  • mutability
  • error handling

Rust is not as scary as people say

So far, it actually feels logical and structured.

Yes, the syntax is different, but it's not impossible to understand.


The Plan

The challenge continues.

My goal is to go from zero to production with Rust.

Over the next posts I will explore:

  • ownership
  • borrowing
  • lifetimes
  • crates
  • building a real project
  • deploying it

And eventually ship something real.


Final Thoughts

The hype around Rust is massive.

But after the first day, one thing is clear:
Rust is just another common language.

Let’s see how far this rabbit hole goes.

Top comments (0)