Preface

Hello, friend! Right from the start, I want to acknowledge that as a little Rustacean I won't delve deeply into Rust's arcane secrets. This mdBook is merely an excuse for me to share my enthusiasm and some thoughts from my journey so far.

If you've come all the way here, I assume you're already on board. So, let's sail together! Hopefully, you will find something valuable within these pages. Even if it's just a small reminder of why choosing Rust was the best decision ever.

Prologue

If there's one lesson that Fullmetal Alchemist Lavoisier teaches us, it's that "Nothing is lost, nothing is created, everything is transformed." Or words to that effect. This means that things will not vanish nor will they be created as if by magic.

In programming, this concept is given the fancy name of 'trade-off', which basically means the same thing: In life, we can't have everything. At least, not at the same time nor out of nowhere. True in Lavoisier’s time, this remains so today. But, holy moly, it's surprising how low our expectations can sometimes be for what we can achieve and deserve in life.

Where I come from, when calling to any technical support, the first thing they will ask you is if you already tried to 'turn it off and on again'. This maneuver is so widely known that people will often lie to the assistant and say they will try to do it once more rather than admit they forgot about it and already wasted a regretful amount of time trying to tackle the problem in a more reasonable way.

I think the shame here is not about how much time you spent with a useless solution, nor how you are trying to tackle the problem in an overcomplicated way. The shame is due to the fact that absolutely everyone expects that the first thing you've tried is to turn the darn thing off, count to 5, and turn it on again. And do you know what the most annoying aspect of it is? It works. This is why it became universal knowledge. It works every single time.

And so, we, as humankind, simply start accepting that things can stop working for no apparent reason. And when this happens, the most reasonable approach to solve it is by turning them off and then on again. "That's just the way things are."

It doesn't matter how much experience we have acquired in life, or how smart or how creative we are. When something stops working unexpectedly, or even worse, when it works but in a really weird and unpredictable way, we sooner rather than later end up just accepting it. At some point, everyone will just give up. And even if one really cares, one will rapidly forget about it: there are things more urgent to occupy us in our modern life.

However, for some of us, the problem is too close to home to simply ignore - as close as the next door, or the elevator, I should say.

Empowerment

If I had to summarize my entire experience with Rust so far in a single paragraph, I would probably end up borrowing the words of Nicholas Matsakis and Aaron Turon:

[...] the Rust programming language is fundamentally about empowerment: no matter what kind of code you are writing now, Rust empowers you to reach farther, to program with confidence in a wider variety of domains than you did before.

The entire text can be found in the Foreword section of The Book.

Before discussing all the doors Rust can open, and all the never-before-imagined domains behind them, I'd like to first delve a little into this concept of empowerment.

rust-fire-mario-equation

The image above comes from a delightful portrait of the Rust community discussion at the very end of 2016, provided by Brian Anderson. Voices back then pointed out that limiting Rust to its safety and low-level programming capabilities wasn't enough, or at least, wouldn't be doing it the appropriate justice. This is where the illustrated metaphor came from: Rust should be seen as the Fire Flower that turns a regular Mario into a badass fireball-throwing Mario.

For me, what makes Rust special is not just the "superpowers" it provides. It's the confidence that comes with it. The certainty of delivering more reliable code right out of the box, and sometimes even receiving a performance improvement as a bonus. This is an experience that changes how you feel about your own code and about your capabilities. This is, for me, what empowerment is about.

The freedom that comes when the self-imposed barriers start to be demolished. The fearless environment where major mistakes can be caught even before compiling your code. And the guidance that prevents disorientation or hopelessness when diving into a lower-level abstraction. This is what empowerment feels like for me. And this, in my opinion, is what makes Rust special and why it's one of the most loved languages ever.

Community

In the previous section, I discussed how my experience with Rust can be summarized as Empowerment. This is true, and I still think that it's a good starting point because it describes the potentials that are more closely related to Rust's aspects as a programming language. And by "programming language", I'm also hinting at the idea of a "tool".

After all, it's the programming language aspects that people first think of and are curious about when reading about one, right? And a programming language is what Rust is, isn't it? Well, both questions can be answered with a simple "yes". But the reasons I'm writing this, and probably the reasons you're reading it, go far beyond that.

If you'll allow me to indulge once again in my old, probably foolish, habit of summarizing and speculating, I would suggest that what lies behind these reasons, or beneath Rust's shiny surface, is a community, really. I realize this could be said for many things, but I think it's particularly true for Rust.

Everything I've said about empowerment, and every aspect I may address here, exists or holds true, because of Rust's community. This applies to the Rust programming language itself as well. So, while the upcoming sections may seem to cover various topics, in reality, I'm simply using different words, or finding new excuses, to talk about this vibrant and welcoming community.

Getting Started

The learn section on Rust's official website provides three different resources for getting started with Rust. Each resource has its own approach, but they all share the common goal of making the learning process as smooth and enjoyable as possible.

There's already a well-produced piece of content about this topic available on youtube. So I'll just say the following: Take your time and remember to have fun. Learning is a lifetime endeavor.

Tooling

Ecosystem

One thing that new Rust developers will face sooner rather than later is the absence of some common utilities typically found in other languages' standard libraries. There are very good reasons fore Rust to be this way. This "batteries included" approach, although seemingly ergonomic at first glance, can have some downsides in the long run.

The fact is, the lean std library is supported by a rich ecosystem that can be easily accessed and incorporated with Cargo. This shifts the problem from "why isn't x available" to "which of all these x options should I choose?!".

This was a real challenge for me in the beginning. I spent a considerable amount of time searching and comparing. To be honest, I think this additional step, where we are expected to pick and choose our own tools, contributed significantly to my learning journey and personal development. I see it as an opportunity to discover more about the ecosystem and to delve deeper into the tools we use.

However, the goal here is to make things easier for you. So, I will share two unofficial "curators" that have explored the vast sea of crates and now are offering us some good starting points.

The first one, and perhaps the more beginner-friendly, is the Blessed guide.

The second, which lacks the "handmade" aspect but offers far more options and criteria, is Lib.rs.

Enjoy!

Documentation

Stability

https://blog.rust-lang.org/2014/10/30/Stability.html

Refresh

Contribution

https://cypherpunks.ca/~iang/pubs/gradingcurve-secdev23.pdf

Real-World

Future

Appendix

Ferris

extra-cute crab

If by any chance you ever wonder who this extra-cute crab is, let me gladly introduce you to Ferris, the unofficial mascot of Rust.

Ferris even has their own special place on the digital sea.