Skip to main content

Command Palette

Search for a command to run...

Rust Experience

I made Rust panic… and somehow I liked it 🥹

Updated
•5 min read
Rust Experience
A
An Engineering Individual

I come from a JavaScript and Python background, where error handling often feels like an optional discipline.

You can handle errors properly, but in many cases, the language does not force you to think about them upfront. Whether you handle an error or ignore it often depends on the developer’s mood, preference, experience, or the urgency of the task.

When I used to see people praise Rust, I often wondered:

What does Rust actually bring to the table that other languages do not?

If you ask AI this question, you will probably get generic answers like memory safety, performance, concurrency, ownership, and zero-cost abstractions. All of that is true, but those answers do not always stick with a developer — at least they did not stick with me.

So I decided to learn Rust out of curiosity and write about them to have better memory retention.

And honestly, I already love this language.

The interesting part is that even while I am still learning, Rust makes me feel like I am writing production-grade code. Not because my code is perfect, but because the language keeps pushing me toward better decisions.

Error Handling Is Not Treated as an Afterthought

Let’s take a very simple example.

In Python, if we want to take input from a user, we usually write something like:

value = input("Enter the value you desire: ")

It looks simple and if you ask me ~ it is simple.

But this simplicity hides several edge cases and always assume it will go happy path but always remember what Madara Uchiha says ~ Wake up to reality—nothing ever goes as planned in this world.

  • What happens if input reading fails?

  • What should the program do if the data is not in the expected format?

  • Where should the error be handled?

  • Should the function return a valid value, an error, or crash?

In many dynamically typed languages, these decisions are pushed to runtime if there is no standard coding practices. The code may look clean, but the failure behavior is not always visible from the structure of the program.

In Rust, reading input from standard input looks something like this:

use std::io;

let mut input = String::new();

io::stdin()
    .read_line(&mut input)
    .expect("Failed to read input");

First, this looks more verbose & that verbosity is not noise.

It is communication.

Rust is making it clear that read_line can fail. It returns a Result, and the developer must decide what to do with that result.

By using expect i am making the decision that if reading from standard input fails, stop the program and show this message.

This is a conscious decision.

And this is one of the things I immediately liked about Rust. The language does not silently let me ignore failure paths ( It will bug me when I will compile the program). It brings them into the structure of the code.

The Compiler Catches Issues Early

The Rust compiler is also great.

It suggests many issues clearly, like when the actual return value does not match the function’s return type. These kinds of problems are better caught at compile time rather than runtime.

In the era of AI, it is really mind-boggling to see that the compiler itself can detect issues on so many levels and guide the developer before the code even runs.

Mutability Is Explicit

Another thing I liked is that variables are not mutable by default.

If we want a variable’s value to change, we need to declare it with the mut keyword:

let mut value = 10;

This tells the compiler that this variable has permission to change from its initial value.

I find this very clean because the code becomes more intentional. If something can change, it is clearly visible in the code.

Macros Are Fascinating

The concept of macros is also very fascinating to me.

In Rust, macros are clearly different from functions. For example:

println!("Hello, Rust!");

The ! makes it clear that this is a macro and not a regular function. Currently learning more on this.

Fun Fact: You Can Make the Thread Panic

Fun fact: Rust is fun to learn because you can make the thread panic through your coding practice.

While learning, I encountered this error:

thread 'main' panicked at src/main.rs:43:42:
called `Result::unwrap()` on an `Err` value: ParseIntError { kind: InvalidDigit }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

It got panicked because of the way I was doing parsing using unwrap(). Totally my fault. :)

Final Thoughts

Currently, I am going through The Rust Programming Language book, and even at this stage, I already feel that Rust is more of a organized language.

The syntax feels clear, and most things make sense once you understand the reason behind them.

Rust feels different because it pushes you to think about correctness from the beginning.

It makes error handling visible.
It makes mutation intentional.
It makes the compiler part of the learning process.

Still learning - very interesting language indeed.