Hello dev community π
First of all, let me introduce myself!
I am a final-year Computer Science undergraduate, a freelance full-stack developer, and DevOps engineer. I have hands-on experience with C++, Java, and Python. Recently, I started exploring Rust, and I quickly realized just how magical of a language it is.
Why Rust?
From my perspective, Rust provides unmatched memory safety guarantees without needing a garbage collector. It strikes a sweet spot low-level enough for system performance, yet high-level enough for ergonomic developer experience.
Once your code compiles, the chance of runtime failure drops drastically. A few things that made me fall in love with Rust:
- Intelligent Compiler: Its helpful error messages read almost like human advice.
- Blazing Fast Execution: Built-in performance optimizations ensure high-speed operations.
-
Modern Tooling:
cargomakes dependency management and building effortless.
While Rust is notorious for its steep learning curve (thanks to the borrow checker!), its world-class documentation, tooling, and supportive community make learning it completely worth the effort!
Getting Started with Rust
1. Installation
- Linux / macOS: Run this command in your terminal:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
-
Windows: Visit the official Rust Installation Guide to download
rustup-init.exe.
2. Creating Your First Project
When you install Rust, you also get Cargo Rustβs official build system and package manager. Cargo handles building your code, downloading libraries, and managing dependencies.
To create a new project, run:
cargo new hello-world
This creates a new folder named hello-world with all the necessary boilerplate.
Navigate inside the project and open src/main.rs.
Hello World with Rust ππ
Inside src/main.rs, you'll see:
fn main() {
println!("Hello, World!");
}
Booyaah!! π₯³ Youβre looking at your first Rust program!
Quick Note: Notice the
!at the end ofprintln!? That means itβs a Rust Macro, not a standard function call. Macros are a form of metaprogramming (code that writes code) and are extremely powerful in Rust. Weβll dive deeper into macros in a future post!
Running the Project
To compile and execute your app, run Cargo's run command in your project root:
cargo run
Youβll see output similar to this:
hello-world git:(master) β cargo run
Compiling hello-world v0.1.0 (/path/to/hello-world)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.86s
Running `target/debug/hello-world`
Hello, World!
What's Next?
This is just the start of my Rust journey! In the upcoming post, I'll cover variables.
Drop a comment below if you're also learning Rust or planning to start! Happy coding! π¦