Mut vs Immutable: Why Rust Makes You Choose

    Go to Rust Series: ← Lifetimes Explained | Series Overview | String vs &str → The Default Difference Go: Everything is mutable by default Rust: Everything is immutable by default This single difference shapes how you write code in each language. Go: Mutable by Default Go: func main() { x := 10 x = 20 // No problem x = x + 5 // No problem fmt.Println(x) // 25 } Variables are mutable unless you use const (which is very limited): const PI = 3.14 // Compile-time constant only PI = 3.14159 // Error Rust: Immutable by Default Rust: ...

    April 25, 2025 · 7 min · Rafiul Alam

    Lifetimes Explained: The Annotation Go Developers Never Needed

    Go to Rust Series: ← No Garbage Collector | Series Overview | Mut vs Immutable → The Concept Go Doesn’t Need Lifetimes are Rust’s way of tracking how long references are valid—all at compile time. Go doesn’t need lifetimes because the garbage collector tracks reference validity at runtime. Rust needs them because there’s no GC. Go: References Just Work Go: func getFirst(a, b string) string { if len(a) > len(b) { return a } return b } func main() { x := "short" y := "longer" result := getFirst(x, y) fmt.Println(result) } No annotations needed. GC ensures result stays valid. ...

    April 24, 2025 · 7 min · Rafiul Alam

    No Garbage Collector: How Rust Manages Memory Without GC

    Go to Rust Series: ← Ownership and Borrowing | Series Overview | Lifetimes Explained → The Fundamental Trade-Off Go: Automatic memory management via garbage collection Rust: Compile-time memory management via ownership Both approaches have profound implications for performance, predictability, and developer experience. How Go’s GC Works Go: func allocateData() { for i := 0; i < 1000000; i++ { data := make([]byte, 1024) // Use data... // No explicit free needed } } Go’s GC: Tracks all allocations Periodically stops the world (STW) Scans for reachable objects Frees unreachable memory GC pause times: Typically 1-10ms, but can spike higher. ...

    April 23, 2025 · 7 min · Rafiul Alam

    Ownership and Borrowing: The Concept Go Doesn't Have

    Go to Rust Series: ← The Rust Compiler | Series Overview | No Garbage Collector → The Core Difference Ownership is Rust’s most important concept—and the one Go completely lacks. In Go, the garbage collector handles memory. In Rust, the ownership system handles memory at compile time, with zero runtime cost. Go’s Approach: Share and GC Go: package main import "fmt" func main() { data := []int{1, 2, 3} // Pass to multiple functions printData(data) modifyData(data) printData(data) // Still usable fmt.Println(data) } func printData(d []int) { fmt.Println(d) } func modifyData(d []int) { d[0] = 999 // Modifies original } Output: ...

    April 22, 2025 · 7 min · Rafiul Alam

    The Rust Compiler: Why It Yells at You (And Go Doesn't)

    Go to Rust Series: ← Setting Up Rust | Series Overview | Ownership and Borrowing → The First Encounter Week 1 with Go: I shipped features. Week 1 with Rust: I fought the compiler. This isn’t a bug—it’s Rust’s design. The compiler is strict, verbose, and often frustrating. But after fighting it for weeks, I realized: it’s actually trying to help me. Compiler Philosophy Go: Trust the Developer Go’s compiler does basic checks and gets out of your way: ...

    April 19, 2025 · 9 min · Rafiul Alam

    Setting Up Rust: Tooling Compared to Go's Simplicity

    Go to Rust Series: ← Hello World Comparison | Series Overview | The Rust Compiler → Installation: First Impressions Go: Download and Done Installation: Go to golang.org/dl Download installer for your OS Run installer Done Verify: $ go version go version go1.22.0 linux/amd64 That’s it. Go is installed. One binary, one version, ready to use. Where it lives: $ which go /usr/local/go/bin/go Single installation directory. Simple. Rust: The Rustup Way Installation: $ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh This installs rustup, Rust’s toolchain manager (like nvm for Node or rbenv for Ruby). ...

    April 18, 2025 · 8 min · Rafiul Alam

    Hello World in Rust: Why It's More Complex Than Go

    Go to Rust Series: ← Cargo vs Go Modules | Series Overview | Setting Up Rust → The “Simple” Hello World Every programming tutorial starts with “Hello, World!” It’s supposed to be trivial. But comparing Go and Rust versions reveals fundamental philosophical differences. Go’s Hello World main.go: package main import "fmt" func main() { fmt.Println("Hello, World!") } Compile and run: go run main.go Output: Hello, World! Done. Five lines. Zero surprises. Rust’s Hello World main.rs: ...

    April 17, 2025 · 7 min · Rafiul Alam

    Cargo vs Go Modules: Package Management Face-Off

    Go to Rust Series: ← Day 1 Impressions | Series Overview | Hello World Comparison → First Impression: Cargo is Actually Great After struggling with Rust’s ownership system on Day 1, I expected the tooling to be equally complex. I was wrong. Cargo is fantastic. Coming from Go modules (which are already pretty good), Cargo feels like a spiritual successor with better UX. Project Initialization Go: mkdir myproject cd myproject go mod init github.com/username/myproject Creates go.mod: ...

    April 16, 2025 · 9 min · Rafiul Alam

    Day 1 with Rust: A Gopher's First Impressions

    Go to Rust Series: Series Overview | Cargo vs Go Modules → The Setup After years of writing Go, I decided to spend a few months learning Rust. Everyone kept talking about “fearless concurrency,” “zero-cost abstractions,” and “memory safety without garbage collection.” As a pragmatic developer, I wanted to see what the fuss was about. Day 1 was… humbling. First Shock: Everything Needs Annotations Coming from Go, where types are inferred elegantly, Rust feels verbose. Here’s my first attempt at a simple function: ...

    April 15, 2025 · 7 min · Rafiul Alam

    HTTP/3 & WebTransport in Go: Next-Generation Real-Time Communication

    {{series_nav(current_post=12)}} HTTP/3 and WebTransport represent the future of web transport protocols, replacing TCP with QUIC (Quick UDP Internet Connections) to eliminate head-of-line blocking, reduce connection establishment latency, and enable new communication patterns. Built on UDP, these protocols offer the reliability of TCP with the flexibility and performance previously only available in custom solutions. What are HTTP/3 and WebTransport? HTTP/3 is the third major version of HTTP, using QUIC instead of TCP as its transport protocol. QUIC provides multiplexed streams, built-in encryption, and faster connection establishment. ...

    February 19, 2025 · 17 min · Rafiul Alam