Casey Muratori | Smart-Pointers, RAII, ZII? Becoming an N+2 programmer
Channel:xDahl · Length:30:12 · Published:2024-07-13 · Views:165024
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
- MIT's Pathway to Fusion Energy (IAP 2017) - Zach Hartwig · MIT Plasma Science and Fusion Center · 1:11:39
- There’s No Wave Function? | Jacob Barandes · Curt Jaimungal · 2:14:30
- Rich Hickey: Deconstructing the Database · InfoQ · 1:06:23
- A Brief History of Quantum Mechanics - with Sean Carroll · The Royal Institution · 56:11
- The world depends on a collection of strange items. They're not cheap · Veritasium · 18:32
- RailsConf 2014 - All the Little Things by Sandi Metz · Confreaks · 38:47
- "Simple Made Easy" - Rich Hickey (2011) · Strange Loop Conference · 1:01:38
- "Making Impossible States Impossible" by Richard Feldman · elm-conf · 25:06
- CppCon 2015: Andrei Alexandrescu “std::allocator...” · CppCon · 1:12:27
- Lexical Scanning in Go - Rob Pike · GoogleFOSSSydney · 51:17
- How To Design A Good API and Why it Matters · Google TechTalks · 1:00:19
- The Value of Values with Rich Hickey · InfoQ · 31:43
- Overwatch Gameplay Architecture and Netcode · GDC Festival of Gaming · 1:04:03
- Solving Problems the Clojure Way - Rafal Dittwald · Clojure/north · 1:02:26
- Lecture 1A: Overview and Introduction to Lisp · MIT OpenCourseWare · 1:12:55
- Alan Kay - Normal Considered Harmful · powerfuloutlet · 1:07:26