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

    Nostalgia as Narrative Engine: Longing for Places That Never Existed

    Close your eyes and think about “the good old days.” Notice something? They’re sun-dappled. Slightly blurry. Emotionally warm. The music is just right. The colors are saturated but gentle. Now ask yourself: Did it really look like that? Or does memory edit with a generous hand? Nostalgia is one of the most powerful narrative engines in storytelling. It’s also one of the trickiest-because the past we’re nostalgic for often never existed. ...

    February 25, 2025 · 8 min · Rafiul Alam

    Earworms: Why Songs Get Stuck in Your Head

    Brain Series Current: Earworms Cocktail Party Effect All Posts Next It’s been three hours since you heard that song. You’re trying to focus on work, but there it is again-playing on an endless loop in your head. ...

    February 15, 2025 · 10 min · Rafiul Alam

    Nostalgia on a Plate: Why We Crave Foods from Our Childhood

    Deeply Personal Current: Nostalgia on a Plate Cats and Empathy All Posts Next Nostalgia on a Plate: Why We Crave Foods from Our Childhood My wife was chopping vegetables when she stopped, knife mid-air, and said: ...

    February 9, 2025 · 10 min · Rafiul Alam

    Unpacking KV Cache Optimization: MLA and GQA Explained

    Introduction: The Memory Wall Modern LLMs can process context windows of 100K+ tokens. But there’s a hidden cost: the KV cache. As context grows, the memory required to store key-value pairs in attention explodes quadratically. This creates a bottleneck: Memory: KV cache can consume 10-100× more memory than model weights Bandwidth: Moving KV cache data becomes the primary latency source Cost: Serving long-context models requires expensive high-memory GPUs Two innovations address this: Grouped Query Attention (GQA) and Multi-Head Latent Attention (MLA). They reduce KV cache size by 4-8× while maintaining quality. ...

    January 31, 2025 · 11 min · Rafiul Alam

    Chunking: How to Remember Phone Numbers (And Everything Else)

    Brain Series Current: Chunking: How to Remember Phone Numbers Previous All Posts The Forgetting Curve Try to memorize this number: 2025551234567. Hard, right? ...

    January 26, 2025 · 8 min · Rafiul Alam

    H.M. and the Mystery of Memory: The Man Trapped in Permanent Now

    On September 1, 1953, a 27-year-old man named Henry Molaison underwent experimental brain surgery to treat his severe epilepsy. The surgery worked. The seizures stopped. But when Henry woke up, he had lost the ability to form new memories. For the next 55 years, until his death in 2008, Henry lived in a perpetual present. Every person he met was a stranger minutes later. Every conversation was new. Every day was the first day of the rest of his life-literally. ...

    January 16, 2025 · 10 min · Rafiul Alam

    The Zeigarnik Effect: Why Cliffhangers Hijack Your Mind

    It’s 2 AM. You tell yourself “just one more episode” for the third time tonight. The show ended on a cliffhanger, and your brain refuses to let you sleep until you know what happens next. Or maybe you’re at work, supposedly focused on a spreadsheet, but part of your brain is still churning over that unfinished novel you put down this morning. Why do unfinished stories occupy so much mental real estate? The answer lies in a phenomenon discovered in a 1920s Berlin restaurant-and it might be the most powerful tool in a storyteller’s arsenal. ...

    December 5, 2024 · 6 min · Rafiul Alam

    Clive Wearing's Eternal Present: A Life Measured in Seconds

    Every few seconds, Clive Wearing wakes up for the first time. He opens his eyes. He looks around. And he experiences what he believes is his first moment of consciousness after years of being unconscious. He writes in his journal: “8:31 AM: Now I am really, completely awake.” A few minutes later, he crosses it out and writes: “9:06 AM: Now I am perfectly, overwhelmingly awake.” Then he crosses that out too and writes: “9:34 AM: NOW I am awake.” ...

    November 30, 2024 · 12 min · Rafiul Alam