π¦ Day 1 of #100DaysOfRust β Why Rust, Cargo, and the Basics
Hey everyone π
Iβm Subesh, a full-stack developer working with React and Node.js. I'm starting my journey into the systems world through Rust β and Iβm doing it in public as part of the #100DaysOfRust challenge.
π Why Rust?
Today I explored why Rust is being adopted by teams at Mozilla, Dropbox, Cloudflare, and more. Hereβs what stood out:
- β High-level language features without performance penalties
- π Compile-time checks enforce safety and prevent bugs
- π§ First-class tooling (
cargo
,rust-analyzer
,rustfmt
) - π§± Strong, expressive type system
- π¦ Simple dependency management (
crates.io
) - π± A rapidly growing ecosystem and a welcoming dev community
It feels like TypeScript met C++ and decided to be nice to developers.
π¦ Understanding Cargo
Rust uses cargo
as its package manager and build system β similar to npm
or yarn
but more integrated.
Here are the commands I learned:
Command | Purpose |
---|---|
cargo new project_name |
Create a new Rust project |
cargo build |
Compile the project in debug mode |
cargo build --release |
Compile with optimizations |
cargo run |
Compile and run the project |
cargo check |
Check for errors without compiling an executable |
Cargo also manages dependencies in a file called Cargo.toml
.
π§ Rust Basics β Variables, Constants & Shadowing
πΈ Variables
- Declared with
let
- Immutable by default β this prevents accidental bugs
- Use
mut
to make them mutable
let immut = 5; // Immutable
let mut x = 5; // Mutable
println!("The value of x is: {x}");
x = 6; // Allowed now
println!("The value of x is: {x}");
πΈ Constants
- Declared with const
- Must include a type annotation
- Cannot be assigned a value thatβs only available at runtime
- Useful for global or shared values
const THREE_HOURS_IN_SECONDS: u32 = 60 * 60 * 3;
println!("Three hours in seconds: {THREE_HOURS_IN_SECONDS}");
πΈ Shadowing
- Allows re-declaring a variable with the same name using let
- The new variable can have a different type
- Shadowing helps avoid unnecessary mutable state
let x = 5;
let x = x + 1;
{
let x = 10;
println!("The value of x after shadowing in the inner scope is: {x}");
}
println!("The value of x after shadowing is: {x} in outer scope");
// With shadowing data types can be changed
let spaces = " "; // Now a string
let spaces = spaces.len(); // Now an integer!
π§Ύ Rust File Naming Conventions
- Use snake_case (e.g., main.rs, my_module.rs)
- File name should match the module name
- Rust source files end with .rs
π¬ Reflections
Rust feels strict, but in a good way. The compiler really wants you to write safe, predictable code. Coming from JavaScript, this shift toward immutability and type safety already feels like a step forward.
Iβm starting to see why developers rave about it.
π Follow the Journey
Iβll be posting updates daily here on Dev.to and on Twitter.
π¦ Twitter: https://x.com/SubeshDev
π GitHub repo: https://github.com/Subeshrock/rust-learning-journey.git
If you're also learning Rust, let me know below! Let's connect and support each other π€
π Coming Up Next:
Data types, functions, comments & control flow
Thanks for reading π
Top comments (0)