Casey Muratori | Smart-Pointers, RAII, ZII? Becoming an N+2 programmer

Channel:xDahl · Length:30:12 · Published:2024-07-13 · Views:165024

Watch on YouTube

Summary

Casey Muratori argues against smart pointers and RAII, advocating grouped-element thinking, zero-is-initialization and stubs as better ways to structure memory and handle errors.

Why HN recommends it

HN commenters in memory management and language design threads cite it as the best explanation of group lifetimes versus per-object ownership.

The best video on this might be from Casey Muratori — HN, 2026

C, C++, Rust, Go & systems languages · Software architecture & design

Subtitles (excerpt)

stock overflow says You must use Smart pointers the handmade Hero codebase has no smart pointers how can this be um so so roughly what I would say um about that is you can imagine if you imagine like a programers life cycle um you know it it looks something like like the following so you know no one's like just a born knowing how to program it's something that you learn and inside your brain you learn to program in in very definitely in stages right and the stages are pretty uh consistent I think and so we won't like I won't try to do you know do them all here but at some point when you go through these stages you get to Stage n and Stage n is I guess what I would call the individual element thinking right right um individual element thinking is when you think of each specific piece of data in your code as having its own lifetime um so for example if you're going to create like in our code we have entities you think about every entity as getting like a new or a malok or you know the first time you create it and then you think of it having like a an end point that its own and that's where you call like delete or the garbage collector you know cleans it up or a smart pointer in this case

On Hacker News

Above poster is talking about thinking in terms of grouped lifetimes and bulk allocations/deallocations, which is better for performance, and makes Rust borrow checking and other RAII style features completely pointless as they don't add any safety benefits. I used to think like you until I watched this video: [VIDEO] I can confirm after exploring programming like the above video explains, that e… — jackclayton, 2026-07
Unfortunately I don't think you've understand what I was I trying to say. Rust was designed from day-0 around explicit individual-value based initialization. Odin from day-0 was not designed around this (explicitly). This ever so minor choice might not seem like a big thing to you, as you have stated in your comment, but it leads to MASSIVE architectural decisions later on when the user programs.… — gingerBill, 2026-01
C and C++ are very different. I think Casey Muratori hits the nail on the head here: [VIDEO] In short, RAII and smart pointers and borrow checker are all signs of "individual element thinking" and that way lies madness. You smear out lifetime and ownership so badly that it practically by definition becomes a problem. Your goal is to think about this stuff in groups to make thinking about allocati… — bsder, 2024-09
This is a hot take, but programming languages haven't progressed since the 90's. We've been conditioned to believe that if you want to be a serious programmer, you have to either use C++-style RAII (which includes Rust), or garbage collection, and there's no in-between, and C programmers are dinosaurs who can be ignored. Arena allocators are a great way to automatically manage memory allocations.… — ChrisTrenkamp, 2026-05
There's a GC library around somewhere, but I doubt anyone uses it. Manual memory management is generally quite simple, as long as you aren't using archaic languages. [VIDEO] is worth a watch. — thegeekpirate, 2025-12

Related videos