Rust has a unique place among programming languages. Apart from being the most loved programming language as often cited in popular surveys, Rust has a distinctive set of features.
It is first and foremost a systems programming language. As one would expect, it is statically typed. In this regard, it is different from dynamic scripting languages like JavaScript and Python. It is also different from popular statically typed languages like C# and Java as it does not have a garbage collector. Rust also doesn’t support inheritance, though it does have polymorphism using triats with dynamic dispatch. Rust is often compared with Go language from Google, both target building efficient software. Here again, the key differentiator is memory management where Go has a garbage collector while Rust doesn’t. So, when it comes to writing performant code, Rust can get closest to the bare metal with its minimal runtime among modern programming languages.
Rust is therefore closer to other system-level programming languages like C/C++ where the memory management is manual. The uniqueness of Rust is the ability to determine at compile time when to deallocate an object’s memory using the concepts of ownership and lifetimes. This frees the developer from explicitly deallocating the memory and eliminates a whole category of bugs like:
- memory leaks
- double free
- dangling pointers
The concept of ownership is similar to RAII (Resource Allocation is Initialization) in C++ while lifetimes are unique to Rust.
So, Rust’s memory safety implemented with zero-cost abstraction is one of the unique selling points. Another is thread-safety where data races can be prevented at compile time.
Learning Rust
Lovingly called ‘The Book’ is the official resource for learning Rust. ‘The book’ is complemented by the ‘Rust by Examples’ tutorial.
Rust book can be a bit dense in some places and examples too long to follow. If you are looking for a gentler explanation of new concepts, then you can go for Easy Rust. It also has a youtube video for each topic of the book.
Though Rust has an official learn-by-doing course called Rustlings, I prefer Exercism which is an awesome platform to sharpen your skills in any of the common programming languages.
I would also recommend the following resources as cheat sheets or a quick refresher:
Good stuff. Thanks for sharing.