🦀 Rust Series 01: What and Why?

🦀 Rust Series 01: What and Why?

·

3 min read

What to expect?

This blog will introduce the Rust programming language by covering its features, applications, and interesting facts. This is the first blog in an upcoming Rust Series. This Series aims to cover concepts related to Rust through projects.

Note: Through these blogs, I have only one goal in mind which is to make devs more comfortable with Rust when starting. The Rust Lang book is well-documented and is a go-to place when you start developing. This is not some master course, it is just the beginning of the world of 🦀 .

What is Rust?

Introduced in 2010, Rust was created at Mozilla Research as a more reliable, safer alternative to C++. "Rust is taking the world of systems programming by storm as it helps you write faster, more reliable software. It is a programming language focused on memory safety, protection, high performance during the processing of large amounts of data, concurrency, and a highly efficient compiler.''

Rust was voted "the most loved programming language" for 7 consecutive years by developers around the globe.

What does it bring to the table?

A few reasons why Rust is loved the most:

  1. Cargo

    Cargo is Rust’s build system and package manager. Cargo - to compile the code, run tests, generate documentation, upload a package to a repository, and much more.

  2. Memory Safety

    Rust's Ownership model prevents data races while avoiding garbage collection. The compiler ensures that references do not outlive the data to which they refer.

  3. No null, No exceptions
    Rust doesn't have a "null" data type. To have a value that can be null, you must explicitly opt-in by making the type of that value as Option . So it's either Some value or None Value. This gives more confidence in writing code.

  4. Error Management
    The compiler generates very accurate and particularly instructive error messages. It also highlights offending code and recommends how to fix it.

  5. Dual Mode
    In Rust, there are two modes of writing code: Safe Rust and Unsafe Rust. Safe Rust imposes additional restrictions on the programmer like object ownership management, thereby ensuring that the code works properly. Unsafe Rust gives the programmer more autonomy, but the code may break.

These features will be covered in depth in the upcoming blogs with examples.

Microsoft is encouraging their developers to rewrite some of their components in Rust because they discovered that most of the security patches are fixes to memory-related bugs, and Rust would’ve been able to catch these bugs during the development phase.

Where is it used the most?

  1. CLI Tools

    The combination of a low-level language with cli-friendly crates and the easiness of publishing and installing the crates with cargo makes the development of CLI Tools a pleasure in Rust.

  2. Web Development

    Rust is a highly suitable language to develop distributed web applications, due to its safety, concurrency, low latency, and low hardware-resource footprint.

  3. Systems Programming
    This is where Rust shines the most. Many large programs have been implemented in Rust, including video game engines, compilers, and operating systems.

Companies like Dropbox, npm, Microsoft, Amazon, Discord, Cloudflare, Figma, Coursera, etc use Rust in production.

Conclusion

Rust is indeed a modern programming language, with more and more developers falling in love with it every day. It does have a steep learning curve, though. But brings additional benefits too. You just have to stick around for a while to get used to it.

What's next?

Next up, we will start with a simple CLI game to cover basic concepts in Rust, see you there. Do feel free to share the feedback with me on Twitter. I would love to hear your thoughts and improve my upcoming blogs in the Rust Series.

Â