Why Learn Rust?
Steve Pryde
Posted on November 27, 2020
In this article I want to share my thoughts on what Rust is really good for, why it exists, and what it can offer you that other languages might not.
I find that when I learn anything new, I first need to have a reason for learning it. There needs to be a purpose. What can it offer me? The same is true for programming languages. Learning anything can bring challenges and some setbacks, and overcoming those is going to be a lot easier if we can answer that simple question... "Why?"
Bugs
I hate bugs. I hate using software that has bugs. I hate it when programs crash, or go slow, or use all of my computer's memory, or leave my data vulnerable to security flaws.
In 2020 we are still using and writing software that has the same bugs, the same mistakes, the same security issues, that were present 20 or even 30 years ago.
The human factor
Most modern programming languages focus on making coding easier, and many have succeeded. But unfortunately they often make coding bugs easier too. We need a change.
Most programming languages still leave it up to the programmer to "get everything right" and it is up to us to remember to put in all of the right safety checks. But programmers are lazy (myself included). We take shortcuts and tell ourselves we'll fix it later. We never fix it later. And so we still have software that crashes.
We tell ourselves that bugs are the programmer's fault. We just need to write better code. Follow better practices. Use better tooling. Become better programmers. Become more experienced.
But is that enough? Even experienced programmers can (and often do) make the same mistakes. We're all human.
Today we have coding guidelines, formatters, linters, static analysis, profilers, benchmarks, unit tests, entire test frameworks, CI/CD, best practices, architects, analysts, experienced software engineers, and open source. And these are all fantastic things that really do help. But they're still not enough.
We still make the same mistakes. Null pointer access, double-free, use-after-free, data races, undefined variables, type mismatch, conversion errors, unhandled exceptions, uncaught errors, and a whole lot more!
Enter Rust
This is why Rust exists. It won't prevent all bugs. No language will do that. But it can prevent entire classes of bugs and that is something we haven't really seen in this industry before in a relatively mainstream language. No null pointers. No data races. Sum types (for more accurate modeling). Exhaustive pattern matching. And a strong focus on correctness and safety by default.
I believe the whole point of Rust, its reason for being, is to allow programmers like you and me to create software that does exactly what we want, with less bugs, and runs faster. By making many types of bugs impossible, I think Rust really does deliver on that goal. Yes it has some new concepts to learn that may be different from other languages, but in return it enables you to create software that is more reliable, with better error handling, and awesome performance. It is not uncommon to spend a little more time fixing errors reported by the compiler, and then much less time debugging.
Last but not least, learning Rust will teach you a lot about common programming mistakes and how to avoid them, even when you're programming in other languages. It will change the way you code everywhere, for the better.
Posted on November 27, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.