Why am I learning the Rust language in 2024?

Meet JainMeet Jain
3 min read

Context

Before getting started to learn rust I gained hands-on experience in front-end and back-end development and have given just the right amount of time to the data structures and algorithms in my college time.

Why Rust?

After doing front-end development in my initial days I did not find front-end development as much interesting as back-end. Building a robust backend that can handle a large throughput is what excites me.

At the same time, I was fascinated by blockchain technology and how crucial it is to build a robust backend and be able to write smart contracts. Also, you can use Rust for building applications using web assembly in the browser.

Features that make Rust a strong language

  1. Memory Management

Rust has good memory management as it has no garbage collector and a minimal runtime. It has a strong focus on preventing common programming errors such as null or dangling pointer references, which can lead to memory safety issues such as buffer overflows and data races.

  1. Concurrency

Rust has built-in support for concurrent programming, making it easier to write efficient and correct concurrent code.

  1. Thread safety

Rust's ownership system ensures that threads cannot access the same memory simultaneously, preventing data races.

  1. Performance

Rust code can be as fast as C or C++ code but with the added safety guarantees provided by the language.

Here’s a Fibonacci sequence up to 35 that takes ~103ms to run as compared to 2s in Python.

use std::time::Instant;

fn fibonacci_rust(n: i32) -> i32 {

if n < 2 {

return n;

} else {

return fibonacci_rust(n-1) + fibonacci_rust(n-2);

} }

fn main() {

let start = Instant::now();

let result = fibonacci_rust(35);

let end = Instant::now();

println! ("Rust : { :?}" , end.duration_since(start));

}

Above all Rust has solved the problem that C++ could not Rust has addressed memory safety issues that C++ struggled with through its unique features, particularly its ownership and borrowing system. This system ensures memory safety by tracking the ownership of values and allowing each value to be used at most once, preventing issues like double-free errors common in C or C++. Additionally, Rust's borrow checking principle emphasizes that mutability and aliasing should not mix, similar to a Read-Write Lock, to prevent memory problems caused by mutable references and aliasing.

Conclusion

Overall, I prefer learning something low-level language to understand the embedded system designs and go in-depth into the language, which seems cool to me. Rust had an ever-growing community for the past few years.

Resources to learn Rust

If you’re looking for something more advanced, the Rust Cookbook is a great resource: https://rust-lang-nursery.github.io/rust-cookbook/

0
Subscribe to my newsletter

Read articles from Meet Jain directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Meet Jain
Meet Jain

Working with blockchain technology and an open-source enthusiast.