DEV Community

Subesh Yadav
Subesh Yadav

Posted on

From TypeScript to Rust – My Journey Begins πŸ¦€

πŸ¦€ 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}");
Enter fullscreen mode Exit fullscreen mode

πŸ”Έ 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}");    
Enter fullscreen mode Exit fullscreen mode

πŸ”Έ 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!
Enter fullscreen mode Exit fullscreen mode

🧾 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)