make handles bold.

This commit is contained in:
ed committed 2026-08-25 16:26:52 -04:00
1 parent f577242432
commit 69b87777e5
728 files changed
+3291 -3087

No files matched your search

@@ -26,9 +26,9 @@ parent_post_id: "1869409243251827152"
## Branch
**1/** @SubstrataVr
**1/** **@SubstrataVr** ^1869424048742232480
@rfleury
**@rfleury**
example?
@@ -26,9 +26,9 @@ parent_post_id: "1869409243251827152"
## Branch
**1/** @TriggerCoder
**1/** **@TriggerCoder** ^1869417818250420400
@rfleury @threadreaderapp
**@rfleury** **@threadreaderapp**
unroll
@@ -26,43 +26,43 @@ parent_post_id: "1869414867113009626"
## Branch
**1/** @cairnc1
**1/** **@cairnc1** ^1869448847807898074
@rfleury
**@rfleury**
At what point do you think you should convert a switch statement to "behavior flags"? Suppose there are N entity types and K behaviors. There should be optimal values of N, K and number of shared behaviors. At least for the purpose of source code length.
**2/** @rfleury
**2/** **@rfleury** ^1869450526154494212
@cairnc1
**@cairnc1**
The problem is that the definition of the problem changes. Assuming there are "entity types" at all is partly the problem. If there is only one entity type, but N possible features for each entity, then there are 2^N possibilities for each individual entity's features.
**3/** @rfleury
**3/** **@rfleury** ^1869450681347895562
@cairnc1
**@cairnc1**
Personally I have found I only very rarely want the switch. I instead want a single type at the bottom, which expands out into these large 2^N spaces, so that a great deal is possible via small changes in data.
**4/** @cairnc1
**4/** **@cairnc1** ^1869454436504043725
@rfleury
**@rfleury**
I prefer behavior flags in theory but I find myself often having very bespoke indecomposable behaviors that correspond 1:1 with a "object". Is it because I am too OOP brained? Fwiw I've only ever programmed in C. I guess it is still a win since sharing behaviors is still easier
**5/** @rfleury
**5/** **@rfleury** ^1869455668157280325
Yeah, I think that is still preferable to "object types". It also makes it much lower friction to decompose them, if/when you see how that should happen. If it never happens, doesn't really matter. For heavier data payloads associated with those specific features, just store them out-of-band.
**6/** @cairnc1
**6/** **@cairnc1** ^1869458573530632619
@rfleury
**@rfleury**
Btw organizing logic this way really makes me wish C had metagen built-in. 😔 I guess we still have X macros
**7/** @rfleury
**7/** **@rfleury** ^1869466426651938890
@cairnc1
**@cairnc1**
Yeah, I get that, although once you have your own general-purpose codebase, it is not a big deal, because *you do* have metagen built in then :)
@@ -26,15 +26,15 @@ parent_post_id: "1869414867113009626"
## Branch
**1/** @count_mascetti
**1/** **@count_mascetti** ^1869425640103129200
@rfleury
**@rfleury**
Maybe you already wrote this somewhere, but I'd be interested in seeing a practical example of your approach, even a basic one. It all sounds very appealing, but I'm struggling to come up with specific use cases.
**2/** @rfleury
**2/** **@rfleury** ^1869426286562816504
@count_mascetti
**@count_mascetti**
https://www.rfleury.com/p/ui-part-3-the-widget-building-language
https://www.rfleury.com/p/emergence-and-composition
@@ -26,27 +26,27 @@ parent_post_id: "1869409243251827152"
## Branch
**1/** @pr0meteu5
**1/** **@pr0meteu5** ^1869438149832946012
@rfleury
**@rfleury**
any concrete example?
**2/** @rfleury
**2/** **@rfleury** ^1869438674062164143
@saddev24
**@saddev24**
- https://www.rfleury.com/p/ui-part-3-the-widget-building-language
- https://www.rfleury.com/p/emergence-and-composition
- https://www.rfleury.com/p/the-codepath-combinatoric-explosion
**3/** @LazarTo42297588
**3/** **@LazarTo42297588** ^1869778968221761675
@rfleury @saddev24
**@rfleury** **@saddev24**
Let's say you're creating a generic table component, with different types of table columns. How will you design the cell render function so it handles all the different types of data that can be displayed: image, url, list, object, button.
**4/** @rfleury
**4/** **@rfleury** ^1869783150899204234
The first thing I’d say is that this is not an architecture I even agree with. Any helpers for constructing a table should build *just the table*, with all UI & rendering capabilities being written by the user.
@@ -26,9 +26,9 @@ parent_post_id: "1869409243251827152"
## Branch
**1/** @spacebat
**1/** **@spacebat** ^1869488275423207781
@rfleury
**@rfleury**
This reminds me of games and simulations, where entities have a set of attributes. That supports the use of entity component systems which gives each entity a key into various tables of related attributes, with subsystems for position/velocity, hit-points, buffs etc.
@@ -26,15 +26,15 @@ parent_post_id: "1869409243251827152"
## Branch
**1/** @Walley_Alex1
**1/** **@Walley_Alex1** ^1869875982645244406
@rfleury
**@rfleury**
I completely agree. I am interested in your thoughts on allowing these megastructure/product types to be used as part of a user API? One issue with product types: it is harder to see what a “valid” set of fields are. With a sum type, they are type checked
**2/** @rfleury
**2/** **@rfleury** ^1869879204361507032
@Walley_Alex1
**@Walley_Alex1**
The idea is more that there *aren’t* invalid subsets of fields. All possibilities are on the table. This is actually more useful for usage code, because the underlying mechanisms are more flexible.
@@ -26,9 +26,9 @@ parent_post_id: "1869409243251827152"
## Branch
**1/** @wetfsdffsdasd
**1/** **@wetfsdffsdasd** ^1870045591582933041
@rfleury
**@rfleury**
interesting projection of combinatorics system into coding system. problem is, none of this yields always. an eg. is when you decouple the system into axbxcxd... such as the space of any of a,b,.. is small, you will be losing sanity and time. there are many other cases too
@@ -26,15 +26,15 @@ parent_post_id: "1869409243251827152"
## Branch
**1/** @s0ulware
**1/** **@s0ulware** ^1882596282017186049
@rfleury
**@rfleury**
thank you for this thread- read it a while ago, but now working on a game and something *clicked* when thinking about modeling data in this way (understanding the power of the 2^n benefit)
**2/** @rfleury
**2/** **@rfleury** ^1882596771396026486
@s0ulware
**@s0ulware**
It’s seriously insane how useful it is, once you see it!
@@ -25,39 +25,39 @@ in_reply_to: ""
## Thread
**1/** @rfleury
**1/** **@rfleury** ^1869409243251827152
One of the most powerful lessons I learned as a programmer was to use combinatoric spaces to my advantage, rather than allowing them to explode into—for example—handwritten source code. This required relaxing, for example, an obsession with static type checking.
Branches: [[archive/threads/rfleury/2024-12-18-one-of-the-most-powerful-lessons-i-learned-as-a/2024-12-18-TriggerCoder-unroll]], [[archive/threads/rfleury/2024-12-18-one-of-the-most-powerful-lessons-i-learned-as-a/2024-12-18-SubstrataVr-example]], [[archive/threads/rfleury/2024-12-18-one-of-the-most-powerful-lessons-i-learned-as-a/2024-12-18-pr0meteu5-any-concrete-example]], [[archive/threads/rfleury/2024-12-18-one-of-the-most-powerful-lessons-i-learned-as-a/2024-12-18-spacebat-this-reminds-me-of-games-and-simulations-where]], [[archive/threads/rfleury/2024-12-18-one-of-the-most-powerful-lessons-i-learned-as-a/2024-12-19-Walley_Alex1-i-completely-agree-i-am-interested-in-your]], [[archive/threads/rfleury/2024-12-18-one-of-the-most-powerful-lessons-i-learned-as-a/2024-12-20-wetfsdffsdasd-interesting-projection-of-combinatorics-system]], [[archive/threads/rfleury/2024-12-18-one-of-the-most-powerful-lessons-i-learned-as-a/2025-01-24-s0ulware-thank-you-for-this-thread-read-it-a-while-ago-but]]
**2/** @rfleury
**2/** **@rfleury** ^1869409245067882985
Instead what I learned was to use static product types to form homogeneous building blocks for large combinatoric spaces, and to organize data transforms around forming those spaces. Choosing actual points in this space becomes a completely dynamic capability.
**3/** @rfleury
**3/** **@rfleury** ^1869410549592989761
This is related to my comment the other day on sum types. The reason you won’t find many of them in my code is that I find that they leak combinatoric spaces into the source code itself, by forming one “axis” (1 of N types), which might be multiplied by another. That puts it in the path of non-temporal physical reality—physical code—which must either be handwritten or generated. This is either slow for the programmer, or for the computer.
**4/** @rfleury
**4/** **@rfleury** ^1869411240227016733
Whereas if you keep the source code looser, with homogeneous types, you can allow defining points & transitioning between points in the combinatoric space to be much more natural & trivial of a computation. In practice this means you’ve turned an O(N*M*…) into an O(N+M+…), for either yourself or the compiler, or code generator (all three are good).
**5/** @rfleury
**5/** **@rfleury** ^1869413198081994912
The fundamental reason for this is machine code, being representable by a transform from A -> B (where A and B are definitions of data formats, or types), must have a shape which expects/fits A as the input, and expects/fits B as the output. A|C -> B means you must have two paths: A -> B | C -> B. This suggests that, as the number of types grows, the number of codepaths must also grow. Or, put another way, the structure of types is reflected in the source code which uses those types.
**6/** @rfleury
**6/** **@rfleury** ^1869413521529966610
You can often see this concretely in C - a discriminated `union` implies a `switch` (or some other branching mechanism on the tag). An array can imply a loop over the indices. A linked list can imply a loop over the links. And so on.
**7/** @rfleury
**7/** **@rfleury** ^1869414204496871475
Thus, when someone attempts to take static type checking to the extreme, and maximally fit all potential data payloads into a format which only stores data which those payloads use (e.g. no unused fields in any case), they are not only exploding the number of types, they are also exploding the number of codepaths.
When confronted with this reality, one impulse is to force compilers or other generators to iterate the combinatoric space manually; this is perhaps preferable to doing it by hand, but what's preferable over both options is to simply avoid the combinatoric space being present in this domain at all.
**8/** @rfleury
**8/** **@rfleury** ^1869414867113009626
This makes distinctions in combinatoric spaces a very trivial data problem, rather than an arbitrarily difficult code problem. It makes the code small, yet the set of possible effects from the code large.
@@ -26,35 +26,35 @@ parent_post_id: "1917431895786414425"
## Branch
**1/** @AnthonyPatch15
**1/** **@AnthonyPatch15** ^1917436903994818849
@rfleury
**@rfleury**
Saw a Casey Muratori video about people who think in single unit lifetimes vs group allocations etc yesterday.
And while I actually agree with both of you, I am believe most of these modern C++ semantics / Rust tries to solve larger team problems.
**2/** @rfleury
**2/** **@rfleury** ^1917437304819572888
@AnthonyPatch15
**@AnthonyPatch15**
There is no evidence to support the idea that these constructs are inherently necessary in larger teams.
**3/** @AnthonyPatch15
**3/** **@AnthonyPatch15** ^1917437823877075415
@rfleury
**@rfleury**
No I don’t intend to try and prove it, they are by nature not.
But what tends to happen in most teams I’ve been part of is that they have some people who are super good and rigorous but also a lot of people who don’t really know what they’re doing - these help the second group.
**4/** @survotreson
**4/** **@survotreson** ^1917510046218346975
@AnthonyPatch15 @rfleury
**@AnthonyPatch15** **@rfleury**
Then the people who don't know what they're doing maybe shouldn't participate and go train ? Kinda sounds like optimizing for the wrong thing here
**5/** @AnthonyPatch15
**5/** **@AnthonyPatch15** ^1917538690223767642
@survotreson @rfleury
**@survotreson** **@rfleury**
In an ideal world yes, never been at a workplace that works like this.
@@ -26,9 +26,9 @@ parent_post_id: "1917431895786414425"
## Branch
**1/** @DomWitczak
**1/** **@DomWitczak** ^1917469208335507559
@rfleury
**@rfleury**
There is exactly zero pain in debugging unique_ptr variables these days. Even with gdb.
@@ -26,9 +26,9 @@ parent_post_id: "1917431895786414425"
## Branch
**1/** @KirillKiriche11
**1/** **@KirillKiriche11** ^1917466585490678240
@rfleury
**@rfleury**
I miss the point you are trying to make
@@ -26,9 +26,9 @@ parent_post_id: "1917431895786414425"
## Branch
**1/** @MoveZig4
**1/** **@MoveZig4** ^1917463363300610136
@rfleury
**@rfleury**
This isn't such a strong argument considering there's a "leak" with the regular call to `new`. To my untrained eye under clang-19 the generated assembly for unique_ptr is a bit smaller/slimmer, with less stack usage - https://godbolt.org/z/sxejEsbe4 - can't turn on -O anything sadly
@@ -26,45 +26,45 @@ parent_post_id: "1917431895786414425"
## Branch
**1/** @Pps831
**1/** **@Pps831** ^1917545684372447392
@rfleury
**@rfleury**
Too much words, but unique_ptr is*really* zero cost. There is no way to go negative in cost there, no matter how much you wish for it 🤣
**2/** @rfleury
**2/** **@rfleury** ^1917562140229304416
@Pps831
**@Pps831**
I recommend you learn to read
**3/** @Pps831
**3/** **@Pps831** ^1917585539068276751
@rfleury
**@rfleury**
I’m ok. But you should at least try to validate if unique_par is zero cost or not. Also, in case you were really complaining about shared_ptr - try to cook something equivalent in c (not just “smart” ptr with ref count, but equivalent)
**4/** @rfleury
**4/** **@rfleury** ^1917585742181851605
@Pps831
**@Pps831**
It isn’t zero cost.
**5/** @Pps831
**5/** **@Pps831** ^1917586343690899661
@rfleury
**@rfleury**
Shared_ptr? Off course, it’s really heavy, but it has incredibly useful functionality.
**6/** @rfleury
**6/** **@rfleury** ^1917586838140903459
@Pps831
**@Pps831**
No, both of them. Neither are useful compared to the alternatives.
**7/** @Pps831
**7/** **@Pps831** ^1917588371930767654
@rfleury
**@rfleury**
If you “really” need the functionality - then it’s great. Most uses don’t really need shared_ptr. If you don’t use it along with “weak_ptr” then you don’t really need it. If you complain about all the allocations, it has solution for the problem: enable_shared_from_this
@@ -26,9 +26,9 @@ parent_post_id: "1917431895786414425"
## Branch
**1/** @Wouter_Bijlsma
**1/** **@Wouter_Bijlsma** ^1917520025348436222
@rfleury
**@rfleury**
Generated assembly or other supposedly better ‘hand-written’ options for memory management are IMO just distractions when talking about unique_ptr. The point of it is to signal and enforce ownership in an API, which can only be a good thing, no? Don’t understand the hate 🤨
@@ -26,9 +26,9 @@ parent_post_id: "1917431895786414425"
## Branch
**1/** @anilcanglk12
**1/** **@anilcanglk12** ^1917498526285603216
@rfleury
**@rfleury**
I bet std comitee wrote thousands of lines for this
@@ -26,9 +26,9 @@ parent_post_id: "1917431895786414425"
## Branch
**1/** @eclectocrat
**1/** **@eclectocrat** ^1917612579972669856
@rfleury
**@rfleury**
I'd use C more if attribute(__cleanup__) was standard and a little less cumbersome. C++ stack unwinding is and always has been it's killer feature.
@@ -26,26 +26,26 @@ parent_post_id: "1917431895786414425"
## Branch
**1/** @mikejt4
**1/** **@mikejt4** ^1917515273680347506
My experience has been different. Every piece of C code I used had weird memory leaks and page faults.
Good C++ with no naked pointers… huge codebase, dozens of developers - never one memory leaks. And performance was fantastic. Maybe not identical to hand-optimized C… but *far* easier to understand and maintain… especially for non god-like developers. We converted everything to C++, including our realtime embedded code. (Medical dev, so regulated, process driven…).
**2/** @rfleury
**2/** **@rfleury** ^1917566795256586508
@mikejt4
**@mikejt4**
Many people have written C in very poor ways, but with the correct approach, it’s (a) simpler, (b) faster, (c) easier to maintain, (d) easier to read
**3/** @dervish_candela
**3/** **@dervish_candela** ^1917699967960953328
@rfleury @mikejt4
**@rfleury** **@mikejt4**
if there is so little code written 'with the correct approach', perhaps 'the correct approach' is in fact anything but easier and simpler
**4/** @rfleury
**4/** **@rfleury** ^1917711908884697362
@dervish_candela @mikejt4
**@dervish_candela** **@mikejt4**
I genuinely have no idea how you think that’s a coherent point—do you think fields simply do not advance?
@@ -26,9 +26,9 @@ parent_post_id: "1917431895786414425"
## Branch
**1/** @shwadev78
**1/** **@shwadev78** ^1917447655128719815
@rfleury
**@rfleury**
Also people will say this garbage and then show you the assembly in -O2. Debug build lives matter!
@@ -26,49 +26,49 @@ parent_post_id: "1917431895786414425"
## Branch
**1/** @AbstrctMachnist
**1/** **@AbstrctMachnist** ^1917754448178188666
@rfleury
**@rfleury**
individual malloc/free is a common C practice and is the fair comparison; group allocations are not the norm in most programs especially in the hand-off ownership situations where unique_ptr would apply. In this light unique_ptr is strictly superior.
**2/** @rfleury
**2/** **@rfleury** ^1917776657131397142
@AbstrctMachnist
**@AbstrctMachnist**
No, it isn’t the fair comparison, because that is not how sensible code is written.
**3/** @AbstrctMachnist
**3/** **@AbstrctMachnist** ^1917780558878249115
@rfleury
**@rfleury**
Okay, well it's a like-vs-like comparison. If used as a straightforward replacement, unique_ptr is better. I concede it's not a replacement for a careful memory strategy.
**4/** @rfleury
**4/** **@rfleury** ^1917782019876217141
@AbstrctMachnist
**@AbstrctMachnist**
But the equivalent code isn’t straightforward. It’s not *careful* to do something better. It’s both *easier and faster*. It is simply the superior way to not use them at all.
**5/** @AbstrctMachnist
**5/** **@AbstrctMachnist** ^1917786181099573679
@rfleury
**@rfleury**
Looking at the RAD Debugger as an example (which is unfair, since you can't look at my code), the diligence of passing an allocator through every function, and being constantly mindful of which pool a given string is coming from, does not seem simple, though it is impressive.
**6/** @rfleury
**6/** **@rfleury** ^1917787214534390012
It isn't through every function, though. And it is not accurate to say you are "constantly mindful" about it. Layers which allocate plan for & control those allocations through a variety of strategies. Most allocations are bucketed into arenas, so the allocation occurs and is forgotten. Anyone who is passed an allocation can use the allocation, they do not have to care about where it came from.
**7/** @AbstrctMachnist
**7/** **@AbstrctMachnist** ^1917790048071598171
@rfleury
**@rfleury**
Alright, but surely this is more thought than probably even 95% of programs give to such things. Nor are most programs developed with such careful attention to layers and their individual memory strategies. And I don't think they should need to, by default.
**8/** @rfleury
**8/** **@rfleury** ^1917791946749403159
@AbstrctMachnist
**@AbstrctMachnist**
*Someone* has to build those layers, is the point. The high level code doesn't have to think about anything. I agree that at those layers, nobody should be having to think about anything other than their problem.
@@ -26,17 +26,17 @@ parent_post_id: "1917431895786414425"
## Branch
**1/** @RokCej
**1/** **@RokCej** ^1918077301998129432
@rfleury
**@rfleury**
Look at any large codebase and you'll see a bunch of new/delete calls. Replacing them with std::unique_ptr would make the code safer without adding any overhead, which was OP's point.
Your argument pertains to a completely different topic and reeks of pretentiousness.
**2/** @rfleury
**2/** **@rfleury** ^1918078091433484469
@RokCej
**@RokCej**
I simply cannot take you seriously
@@ -26,69 +26,69 @@ parent_post_id: "1917431895786414425"
## Branch
**1/** @slendidev
**1/** **@slendidev** ^1917745453656940712
@rfleury
**@rfleury**
Do you have any example of this?
**2/** @rfleury
**2/** **@rfleury** ^1917746479185420605
@xslendix
**@xslendix**
Example of what?
**3/** @slendidev
**3/** **@slendidev** ^1917748674907537414
@rfleury
**@rfleury**
Of where stripping the smart pointers and other RAII stuff leads to simpler memory management (less allocations, less computation)
**4/** @rfleury
**4/** **@rfleury** ^1917749336869687610
@xslendix
**@xslendix**
I have written several 100K LOC that is completely public that you can go look at and compare with other approaches
**5/** @slendidev
**5/** **@slendidev** ^1918322410652160032
@rfleury
**@rfleury**
From looking at RADDbg, most of those allocations are avoided by using an arena. How is this any different from passing in an arena to a string for example instead of using the standard allocator?
**6/** @rfleury
**6/** **@rfleury** ^1918327964212887930
@xslendix
**@xslendix**
It’s completely flipped from the usual RAII approach. Allocated things do not manage themselves. They don’t “know” about their allocator. Everything is just data organized into large buckets. As such, there are no destructors to insert, because there is no freeing to do.
**7/** @slendidev
**7/** **@slendidev** ^1918329072754491448
@rfleury
**@rfleury**
You can just make the free method of the allocator be empty. If the arena is block based (growing arena) then you can also absolutely use that free method to re-use memory in previous blocks.
**8/** @rfleury
**8/** **@rfleury** ^1918329401093378456
@xslendix
**@xslendix**
There’s no point.
**9/** @slendidev
**9/** **@slendidev** ^1918329782145802416
@rfleury
**@rfleury**
Sure, but then you can still make that free method empty
**10/** @rfleury
**10/** **@rfleury** ^1918329939671334989
@xslendix
**@xslendix**
Or you can just not do any of this ridiculous RAII nonsense at all.
**11/** @slendidev
**11/** **@slendidev** ^1918330778351804805
@rfleury
**@rfleury**
At that point it’s just personal preference on wether you want your frees explicit or not in the code. Don’t think having an empty free method adds any overhead either since the compiler can just exclude the destructor entirely because of inlining
@@ -26,9 +26,9 @@ parent_post_id: "1917431895786414425"
## Branch
**1/** @wmcoyne
**1/** **@wmcoyne** ^1917753799021646262
@rfleury
**@rfleury**
Well said. Zero-overhead in the abstract isn't the same as zero-complexity in practice. Hand-coding forces you to confront design directly, not just inherit layers of generic indirection. Sometimes simpler really is better—especially when it matches your problem more precisely.
@@ -25,7 +25,7 @@ in_reply_to: ""
## Thread
**1/** @rfleury
**1/** **@rfleury** ^1917431895786414425
To the degree this is true, it’s only in a technical sense. When you actually force yourself to inline all of the extra nonsense that is implicitly happening in modern C++ codebases, it quickly becomes obvious that something is wrong, and it’s an enormously subpar solution.
@@ -37,40 +37,40 @@ Not to mention the fact that your compile times become way faster, all of your d
Branches: [[archive/threads/rfleury/2025-04-30-to-the-degree-this-is-true-its-only-in-a/2025-04-30-AnthonyPatch15-saw-a-casey-muratori-video-about-people-who-think]], [[archive/threads/rfleury/2025-04-30-to-the-degree-this-is-true-its-only-in-a/2025-04-30-shwadev78-also-people-will-say-this-garbage-and-then-show]], [[archive/threads/rfleury/2025-04-30-to-the-degree-this-is-true-its-only-in-a/2025-04-30-MoveZig4-this-isnt-such-a-strong-argument-considering]], [[archive/threads/rfleury/2025-04-30-to-the-degree-this-is-true-its-only-in-a/2025-04-30-KirillKiriche11-i-miss-the-point-you-are-trying-to-make]], [[archive/threads/rfleury/2025-04-30-to-the-degree-this-is-true-its-only-in-a/2025-04-30-DomWitczak-there-is-exactly-zero-pain-in-debugging-unique]], [[archive/threads/rfleury/2025-04-30-to-the-degree-this-is-true-its-only-in-a/2025-04-30-anilcanglk12-i-bet-std-comitee-wrote-thousands-of-lines-for]], [[archive/threads/rfleury/2025-04-30-to-the-degree-this-is-true-its-only-in-a/2025-04-30-mikejt4-my-experience-has-been-different-every-piece-of-c]], [[archive/threads/rfleury/2025-04-30-to-the-degree-this-is-true-its-only-in-a/2025-04-30-Wouter_Bijlsma-generated-assembly-or-other-supposedly-better]], [[archive/threads/rfleury/2025-04-30-to-the-degree-this-is-true-its-only-in-a/2025-04-30-Pps831-too-much-words-but-unique-ptr-is-really-zero-cost]], [[archive/threads/rfleury/2025-04-30-to-the-degree-this-is-true-its-only-in-a/2025-04-30-eclectocrat-id-use-c-more-if-attribute-cleanup-was-standard]], [[archive/threads/rfleury/2025-04-30-to-the-degree-this-is-true-its-only-in-a/2025-05-01-slendidev-do-you-have-any-example-of-this]], [[archive/threads/rfleury/2025-04-30-to-the-degree-this-is-true-its-only-in-a/2025-05-01-wmcoyne-well-said-zero-overhead-in-the-abstract-isnt-the]], [[archive/threads/rfleury/2025-04-30-to-the-degree-this-is-true-its-only-in-a/2025-05-01-AbstrctMachnist-individual-malloc-free-is-a-common-c-practice-and]], [[archive/threads/rfleury/2025-04-30-to-the-degree-this-is-true-its-only-in-a/2025-05-01-RokCej-look-at-any-large-codebase-and-youll-see-a-bunch]]
**2/** @SubstrataVr
**2/** **@SubstrataVr** ^1917436352578347222
@rfleury
**@rfleury**
I think you may be thinking of shared_ptr, which does reference counting. unique_ptr doesn't need to.
**3/** @rfleury
**3/** **@rfleury** ^1917436636163706994
@SubstrataVr
**@SubstrataVr**
You’re right about the reference counts, my mistake. The other points still stand however.
**4/** @static_assert_0
**4/** **@static_assert_0** ^1917583100604813710
@rfleury @SubstrataVr
**@rfleury** **@SubstrataVr**
In general maybe, but I don’t really see how any of this stands for unique_ptr - it literally is just a struct around a pointer with a deleted copy constructor to give you a compile error when you try to share it?
Now the debugger argument that this adds extra noise is valid
**5/** @rfleury
**5/** **@rfleury** ^1917586421050925263
@static_assert_0 @SubstrataVr
**@static_assert_0** **@SubstrataVr**
I wear certainly conflating the two (I do not use these features) but the argument stands, given that the places where you actually have “owned pointers” should be extremely small. This is seen as useful when you have 1000s of these. But you shouldn’t.
**6/** @AbstrctMachnist
**6/** **@AbstrctMachnist** ^1917756459321786491
@rfleury @static_assert_0 @SubstrataVr
**@rfleury** **@static_assert_0** **@SubstrataVr**
I think this is a perspective difference between game developers, who have natural shared memory lifetimes in the form of frames, data batches, or update ticks, and general purpose developers where it's normal to have many operations in-flight with no common enclosing lifetime.
**7/** @rfleury
**7/** **@rfleury** ^1917776947574366253
@AbstrctMachnist @static_assert_0 @SubstrataVr
**@AbstrctMachnist** **@static_assert_0** **@SubstrataVr**
This is not true. There are lifetimes all over the place in all fields. Everyone just lumps me into “game developers”, but I don’t even work on games professionally? How does your theory account for that? Do you think group lifetimes are somehow unique to games?
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @0x6e616461
**1/** **@0x6e616461** ^2061659934119354768
@rfleury
**@rfleury**
I like using lambdas or local functions to extract some common logic and put it behind a good name without cluttering things up outside
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @AlexAegis
**1/** **@AlexAegis** ^2061831568537071703
@rfleury
**@rfleury**
yes! A similar problem comes when you follow retarded bob martin-esque rules like not exceeding 6 lines per function. You can end up having a bunch of small functions mutating one common state that are now dependent on their call order. That’s not any better than a comment.
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @Arrghtv
**1/** **@Arrghtv** ^2061670156401611263
@rfleury
**@rfleury**
I completely agree, adding a helper function rarely reduces complexity and often leads to a lot of argument bloat.
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @ChickenBurner2
**1/** **@ChickenBurner2** ^2061723452571082945
@rfleury
**@rfleury**
oh I hate helper functions, especially the ones that get used exactly once and serve no purpose but hiding code
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @JoelStransky
**1/** **@JoelStransky** ^2061851334278877273
@rfleury
**@rfleury**
I've come to refer to declarative as "just fucking say it" coding.
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @Mallchad
**1/** **@Mallchad** ^2061632296784941234
@rfleury
**@rfleury**
I've been compressing in terms of "section functions" as opposed to helper functions. I find the concept of small functions teniously useful.
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @MrModez
**1/** **@MrModez** ^2061700108933365773
@rfleury
**@rfleury**
I noticed focusing on the data you work and how you work on it helps a lot
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @Ravicale
**1/** **@Ravicale** ^2061912906921304345
@rfleury
**@rfleury**
I'll often inline every 'helper function' I find while coding. This frequently lets me find more general patterns that can be more compactly expressed, and it also often results in me finding removable state that existed because of coupling between 'helpers'.
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @SaladeTomate18
**1/** **@SaladeTomate18** ^2061680147627958466
@rfleury
**@rfleury**
Entry point you mean indirection ?
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @alienorg
**1/** **@alienorg** ^2061739363117973966
@rfleury
**@rfleury**
fewer entry points = fewer surprises
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @anicic_filip
**1/** **@anicic_filip** ^2061769712824995927
@rfleury
**@rfleury**
I'm not exactly sure what do you mean with this statement. Could you give a comparison example to solidify the statement with something we could analyse?
@@ -26,13 +26,13 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @eron_wolf
**1/** **@eron_wolf** ^2061625769684566075
@rfleury
**@rfleury**
I like giant matching functions with lots of helper functions as closures with limited scope. At least then you're kinda containing the mess.
**2/** @rfleury
**2/** **@rfleury** ^2061627148432216213
That is definitely fair; I build as C (and I want to build with MSVC as well as the others, so I don't have all of the extensions), so I do not have local functions and certainly not closures, but I often find myself approximating similar patterns with command buffers. That said, I still find the statically linear flow preferable when possible.
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @gcoum
**1/** **@gcoum** ^2061640674576101837
@rfleury
**@rfleury**
Only way to compress is dsl vv everything else is just the dsl with some extra boilerplate
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @guywald
**1/** **@guywald** ^2061801368533315756
@rfleury
**@rfleury**
100% agree, DRY can be extremely overdone. LLMs love doing this especially…
There is also a huge price for cognitive complexity, for anyone, human or otherwise, that works on a codebase.
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @jrjnorton
**1/** **@jrjnorton** ^2061639688935317743
@rfleury
**@rfleury**
Do you have an example or a before and after by chance?
I don't find myself pulling out helper functions too often anymore so I'm having trouble thinking of what that looks like in practice
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @jshurmer
**1/** **@jshurmer** ^2061626322707734909
@rfleury
**@rfleury**
Very well said.
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @katanadash
**1/** **@katanadash** ^2061904729975001095
@rfleury
**@rfleury**
My mental model for this: Are you putting the mess in a closet, or are you actually organizing the it?
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @ndwork
**1/** **@ndwork** ^2061896821023383829
@rfleury
**@rfleury**
A function explicitly limits the variables that its code depends on.
@@ -36,15 +36,15 @@ For many functions, they can be independently tested. When possible, that also s
These things make functions extremely useful.
**2/** @rfleury
**2/** **@rfleury** ^2061955393216200840
No. By adding entry points which are independently tested (e.g. in a vacuum, removed from context), you are combinatorially increasing the number of possible test cases. It’s vastly easier to exercise one single codepath than several thousands.
Second of all, sub-scopes also allow limiting exposed variables to other scopes. If a scope fairly far into a function depends on the entire set of exposed variables that came before, functions do not stop that, because you’d simply need to pass them all. There is way less boilerplate and way less complexity in the single codepath version.
**3/** @ndwork
**3/** **@ndwork** ^2062015909842350192
@rfleury
**@rfleury**
I’m taking the fact that you didn’t tell me to delete my account as a huge mark of success. :)
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @patrickgwsmith
**1/** **@patrickgwsmith** ^2061690097158815943
@rfleury
**@rfleury**
I like this as it maps the problem with input on one side and output on the other.
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @pbwinston
**1/** **@pbwinston** ^2061774820073734389
@rfleury
**@rfleury**
Does this imply if you took an external dependency, like Linux or matrix library, and started folding that code into your own, instead of calling into it, your code would improve?
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @pegvvin
**1/** **@pegvvin** ^2061783632067633224
@rfleury
**@rfleury**
Can't tell just how many times I've pulled out something into it's own function only to use it once. I was taught "clean code" incorrectly.
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @polloimperial
**1/** **@polloimperial** ^2061632717666623787
@rfleury
**@rfleury**
I got a mess (kind of working fine but dirty) with c# extensions.
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @sipubot
**1/** **@sipubot** ^2061782202275524654
@rfleury
**@rfleury**
db 설계에 앞서 모든데이터를 파일 입출력 으로 해서 최소 부하를 해보는것도 도움이됨
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @vf42
**1/** **@vf42** ^2061694115520164235
@rfleury
**@rfleury**
Never thought of helper f-ns as code compression, you still have all the same stuff elsewhere. Not to say it's useless.
For the compression exercise ypu mention, I like to add a twist "...and make it easier to understand", which unlocks a whole new level to it.
@@ -26,35 +26,35 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @wizplum
**1/** **@wizplum** ^2061622209383379247
@rfleury
**@rfleury**
What about polymorphism and inheritance?
**2/** @rfleury
**2/** **@rfleury** ^2061622448395800693
@wizplum
**@wizplum**
Largely useless and terrible
**3/** @SaladeTomate18
**3/** **@SaladeTomate18** ^2061680038076961252
@rfleury @wizplum
**@rfleury** **@wizplum**
You still need callback for buttons OnClick.
I assume that's why you said largely (99%) and not always (100%)
**4/** @rfleury
**4/** **@rfleury** ^2061974675253850514
@SaladeTomate18 @wizplum
**@SaladeTomate18** **@wizplum**
No, you don’t. You shouldn’t even have that concept. It’s not a good design.
**5/** @SaladeTomate18
**5/** **@SaladeTomate18** ^2061977183749357731
@rfleury @wizplum
**@rfleury** **@wizplum**
How would you handle it ?
@@ -62,17 +62,17 @@ It is totally not my domain so I am just repeating basic patterns I've seen in m
Thinking about it on the spot all I see is using IDs on buttons and a big switch.
**6/** @rfleury
**6/** **@rfleury** ^2061981087572832590
@SaladeTomate18 @wizplum
**@SaladeTomate18** **@wizplum**
Check this out
https://youtu.be/Z1qyvQsjK5Y
**7/** @SaladeTomate18
**7/** **@SaladeTomate18** ^2062024788810309926
@rfleury @wizplum
**@rfleury** **@wizplum**
Already watched it years ago 😅
@@ -80,9 +80,9 @@ I thought we were talking specifically retained UI. Not Immediate ones.
I do have some friends that worked on AAA with IM UI and they told me performance was not good compared to retained mode (could be just bad code ofc)
**8/** @rfleury
**8/** **@rfleury** ^2062029958340563373
@SaladeTomate18 @wizplum
**@SaladeTomate18** **@wizplum**
Even with retained mode you do not need callbacks. But no, your friends are incorrect. There is nothing in principle about IM UI that makes it less performant than RM. In many cases it’s quite the opposite.
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @0paperpal
**1/** **@0paperpal** ^2062097820493193622
@rfleury
**@rfleury**
will love to read a long article on this
@@ -26,15 +26,15 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @alecodex
**1/** **@alecodex** ^2062309622510170465
@rfleury
**@rfleury**
Can you share an open source project that follows this strategy? As someone deeply entrenched in the web and java world, I am finding it hard to wrap my head around.
**2/** @rfleury
**2/** **@rfleury** ^2062314977915294078
@alecodex
**@alecodex**
https://github.com/EpicGamesExt/raddebugger
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @javiercbk
**1/** **@javiercbk** ^2061970388205146329
@rfleury
**@rfleury**
rad debugger is easy to read for such a complex project, I'm experimenting with the same long proc and noticed that when I add something I'm not constrained to early abstractions, I can connect dots much easier. Yet I have to resist years of brain programming for programming
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @jeremdak
**1/** **@jeremdak** ^2061966313636131122
@rfleury
**@rfleury**
I like a big ass on my functions.
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @p_mbanugo
**1/** **@p_mbanugo** ^2062293339030843846
@rfleury
**@rfleury**
Interesting! I was just reviewing code and thinking of solution when I read this tweet and realised "table + removing enum" solved it better than expecting the helper function to be used correctly.
@@ -26,9 +26,9 @@ parent_post_id: "2061619837877780961"
## Branch
**1/** @partnano
**1/** **@partnano** ^2062209120782966979
@rfleury
**@rfleury**
Do you have a code example of how you would compress / simplify something?
I think I agree, and really need to be more mindful in my next coding session about it, but there's nothing specific coming to my mind, reading your post 😅
@@ -25,7 +25,7 @@ in_reply_to: ""
## Thread
**1/** @rfleury
**1/** **@rfleury** ^2061619837877780961
The first way people usually learn code compression is by pulling common things out into helper functions, but in my view the complexity of adding a new entry point is often overlooked, and things quickly turn into a mess.
@@ -33,6 +33,6 @@ It’s a useful exercise to try compressing code without helper functions, and i
Branches: [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-02-wizplum-what-about-polymorphism-and-inheritance]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-02-eron_wolf-i-like-giant-matching-functions-with-lots-of]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-02-jshurmer-very-well-said-it-would-be-useful-to-see-examples]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-02-Mallchad-ive-been-compressing-in-terms-of-section]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-02-polloimperial-i-got-a-mess-kind-of-working-fine-but-dirty-with]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-02-jrjnorton-do-you-have-an-example-or-a-before-and-after-by]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-02-gcoum-only-way-to-compress-is-dsl-vv-everything-else-is]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-02-0x6e616461-i-like-using-lambdas-or-local-functions-to]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-02-Arrghtv-i-completely-agree-adding-a-helper-function]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-02-SaladeTomate18-entry-point-you-mean-indirection]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-02-patrickgwsmith-i-like-this-as-it-maps-the-problem-with-input-on]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-02-vf42-never-thought-of-helper-f-ns-as-code-compression]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-02-MrModez-i-noticed-focusing-on-the-data-you-work-and-how]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-02-ChickenBurner2-oh-i-hate-helper-functions-especially-the-ones]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-02-alienorg-fewer-entry-points-fewer-surprises]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-02-anicic_filip-im-not-exactly-sure-what-do-you-mean-with-this]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-02-pbwinston-does-this-imply-if-you-took-an-external]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-02-sipubot-db]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-02-pegvvin-cant-tell-just-how-many-times-ive-pulled-out]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-02-guywald-100-agree-dry-can-be-extremely-overdone-llms-love]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-02-AlexAegis-yes-a-similar-problem-comes-when-you-follow]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-02-JoelStransky-ive-come-to-refer-to-declarative-as-just-fucking]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-02-ndwork-a-function-explicitly-limits-the-variables-that]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-02-katanadash-my-mental-model-for-this-are-you-putting-the-mess]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-02-Ravicale-ill-often-inline-every-helper-function-i-find]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-03-jeremdak-i-like-a-big-ass-on-my-functions]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-03-javiercbk-rad-debugger-is-easy-to-read-for-such-a-complex]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-03-0paperpal-will-love-to-read-a-long-article-on-this]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-03-partnano-do-you-have-a-code-example-of-how-you-would]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-03-p_mbanugo-interesting-i-was-just-reviewing-code-and]], [[archive/threads/rfleury/2026-06-02-the-first-way-people-usually-learn-code/2026-06-03-alecodex-can-you-share-an-open-source-project-that-follows]]
**2/** @rfleury
**2/** **@rfleury** ^2061621706834501685
(It also naturally organizes work by computational requirements rather than abstract similarity, which simplifies code but also puts you in a much better position to make performance considerations)
@@ -26,9 +26,9 @@ parent_post_id: "2085786822387609939"
## Branch
**1/** @JaceCear
**1/** **@JaceCear** ^2085790906993541499
@rfleury
**@rfleury**
If you got a concrete example of this, it might be worth making a video out of that, just saying! 😋
@@ -26,9 +26,9 @@ parent_post_id: "2085786822387609939"
## Branch
**1/** @adam_bobowski
**1/** **@adam_bobowski** ^2085799786717049322
@rfleury
**@rfleury**
Overall I’ve noticed that inlining is just amazing at surfacing issues with what the actual „abstraction” is - kind of that if I carve the function too early I’ll obfuscate the fact that maybe the actual function (behaviour) bends to that function rather than the other way around
@@ -26,21 +26,21 @@ parent_post_id: "2085786822387609939"
## Branch
**1/** @borrowck_novel
**1/** **@borrowck_novel** ^2085804992540143894
@rfleury
**@rfleury**
Assuming -O3, if you compare the assembly output before and after the exercise, do you see any meaningful difference?
**2/** @rfleury
**2/** **@rfleury** ^2085809430130803034
@ZH1YGD
**@ZH1YGD**
Yes, absolutely
**3/** @borrowck_novel
**3/** **@borrowck_novel** ^2085812641507807328
@rfleury
**@rfleury**
Thanks a ton. Then it is worth the time to do my own test. Cheers
@@ -26,9 +26,9 @@ parent_post_id: "2085786822387609939"
## Branch
**1/** @calvinalkan
**1/** **@calvinalkan** ^2085812408988180668
@rfleury
**@rfleury**
Do you have a favorite example from raddbg to look at?
@@ -26,13 +26,13 @@ parent_post_id: "2085786822387609939"
## Branch
**1/** @davidvaughn006
**1/** **@davidvaughn006** ^2085797125221179877
@rfleury
**@rfleury**
This seems like such good advice and hard to visualize without having practiced a couple of times. Are there any good programming problems that would lend themselves to this kind of organizational refactoring?
**2/** @rfleury
**2/** **@rfleury** ^2085798544817135767
It is pretty much any time you are dealing with code without regards for this. When someone isn't thinking about this, they will generate lots of redundant layers of helper functions or abstractions, and if you do a clean-up pass over it, you'll find that like 90% of it is nonsense.
@@ -26,9 +26,9 @@ parent_post_id: "2085786822387609939"
## Branch
**1/** @jsuarez
**1/** **@jsuarez** ^2085822235907162194
@rfleury
**@rfleury**
This is the first thing I do in every big refactor
@@ -26,9 +26,9 @@ parent_post_id: "2085786822387609939"
## Branch
**1/** @sandovin34721
**1/** **@sandovin34721** ^2085804624213098970
@rfleury
**@rfleury**
btw this sounds like a nice feature for a debugger
like 'peek definition' in Visual Studio
@@ -26,9 +26,9 @@ parent_post_id: "2085786822387609939"
## Branch
**1/** @tralamazza
**1/** **@tralamazza** ^2085794821310906608
@rfleury
**@rfleury**
couldn't resist
@@ -26,9 +26,9 @@ parent_post_id: "2085786822387609939"
## Branch
**1/** @zygohistoprepro
**1/** **@zygohistoprepro** ^2085814140040266159
@rfleury
**@rfleury**
I did this process to linearise the mutually recursive eval loop of a language - also found a very nice opportunistic TCO due to it.
@@ -26,9 +26,9 @@ parent_post_id: "2085786822387609939"
## Branch
**1/** @TylerCLaprade
**1/** **@TylerCLaprade** ^2085913835706159301
@rfleury
**@rfleury**
John Carmack wrote about this: http://number-none.com/blow/john_carmack_on_inlined_code.html
@@ -26,9 +26,9 @@ parent_post_id: "2085786822387609939"
## Branch
**1/** @patrickgwsmith
**1/** **@patrickgwsmith** ^2085887028353441943
@rfleury
**@rfleury**
Some people will say that a good abstraction lets you understand the loops underneath, and some will say that a good abstraction means you don’t have to understand the loops underneath.
@@ -26,9 +26,9 @@ parent_post_id: "2085786822387609939"
## Branch
**1/** @rep_movsd
**1/** **@rep_movsd** ^2085955766578823628
@rfleury
**@rfleury**
The fundamental property of abstraction is to avoid repetition.
@@ -26,9 +26,9 @@ parent_post_id: "2085786822387609939"
## Branch
**1/** @dvygh
**1/** **@dvygh** ^2086445668743168442
@rfleury
**@rfleury**
makes me wonder why we don't have a tool (do we?) to visualize inlining like that (without actually doing it). maybe stop inlining at certain library call boundaries. not only to evaluate quality, but also to understand what the hell a function is doing.
@@ -25,14 +25,14 @@ in_reply_to: ""
## Thread
**1/** @rfleury
**1/** **@rfleury** ^2085786822387609939
A good way to evaluate one axis of quality of an abstraction is to inline every function call, and see how much duplicate work you can either deduplicate or turn into a loop (rather than several independent function calls). This also restructures the code such that you can consider work as batches of identically shaped work, rather than either (a) being in shallow callstack code and dealing with a list of abstract, opaque function calls, or (b) being in deep callstack code and not understanding the context you're being called within.
Branches: [[archive/threads/rfleury/2026-08-07-a-good-way-to-evaluate-one-axis-of-quality-of-an/2026-08-07-JaceCear-if-you-got-a-concrete-example-of-this-it-might-be]], [[archive/threads/rfleury/2026-08-07-a-good-way-to-evaluate-one-axis-of-quality-of-an/2026-08-07-tralamazza-couldnt-resist]], [[archive/threads/rfleury/2026-08-07-a-good-way-to-evaluate-one-axis-of-quality-of-an/2026-08-07-davidvaughn006-this-seems-like-such-good-advice-and-hard-to]], [[archive/threads/rfleury/2026-08-07-a-good-way-to-evaluate-one-axis-of-quality-of-an/2026-08-07-adam_bobowski-overall-ive-noticed-that-inlining-is-just-amazing]], [[archive/threads/rfleury/2026-08-07-a-good-way-to-evaluate-one-axis-of-quality-of-an/2026-08-07-sandovin34721-btw-this-sounds-like-a-nice-feature-for-a]], [[archive/threads/rfleury/2026-08-07-a-good-way-to-evaluate-one-axis-of-quality-of-an/2026-08-07-borrowck_novel-assuming-o3-if-you-compare-the-assembly-output]], [[archive/threads/rfleury/2026-08-07-a-good-way-to-evaluate-one-axis-of-quality-of-an/2026-08-07-calvinalkan-do-you-have-a-favorite-example-from-raddbg-to]], [[archive/threads/rfleury/2026-08-07-a-good-way-to-evaluate-one-axis-of-quality-of-an/2026-08-07-zygohistoprepro-i-did-this-process-to-linearise-the-mutually]], [[archive/threads/rfleury/2026-08-07-a-good-way-to-evaluate-one-axis-of-quality-of-an/2026-08-07-jsuarez-this-is-the-first-thing-i-do-in-every-big-refactor]], [[archive/threads/rfleury/2026-08-07-a-good-way-to-evaluate-one-axis-of-quality-of-an/2026-08-08-patrickgwsmith-some-people-will-say-that-a-good-abstraction-lets]], [[archive/threads/rfleury/2026-08-07-a-good-way-to-evaluate-one-axis-of-quality-of-an/2026-08-08-TylerCLaprade-john-carmack-wrote-about-this-http-number-none]], [[archive/threads/rfleury/2026-08-07-a-good-way-to-evaluate-one-axis-of-quality-of-an/2026-08-08-rep_movsd-the-fundamental-property-of-abstraction-is-to]], [[archive/threads/rfleury/2026-08-07-a-good-way-to-evaluate-one-axis-of-quality-of-an/2026-08-09-dvygh-makes-me-wonder-why-we-dont-have-a-tool-do-we-to]]
**2/** @niftynathanj
**2/** **@niftynathanj** ^2085788944814277107
@rfleury
**@rfleury**
distance from main sequence