News for hackers. Stuff that matters.
Re:Repeat yourself, do more than one thing, and rewrite ever... by thfuran on Tuesday March 14, 2023 @04:07PM (#35157614)
Inlining is the compiler's job, not mine.
Re:Repeat yourself, do more than one thing, and rewrite ever... by commandersaki on Tuesday March 14, 2023 @10:15PM (#35162847)
You probably should read the article as Carmack makes the case for inlining as a style, not inlining as an optimisation.
Re:Repeat yourself, do more than one thing, and rewrite ever... by thfuran on Wednesday March 15, 2023 @07:43AM (#35166719)
I did read the article. I think I'm less in favor of that style than he is (or at least was), but even he said that the problems it addresses arise from subroutines not being pure functions and so isn't a proponent of it in the case the comment you replied to was describing. And when not writing in that style, inlining is for the compiler to do.
Re:Repeat yourself, do more than one thing, and rewrite ever... by commandersaki on Friday March 24, 2023 @01:20AM (#35285349)
The original poster said if you chop a big hairy complicated thing into functions to fit on a screen you've gained nothing. The response is that if they're named reasonably and pure then you have.

Now the reason I posted that inlining article from Carmack leans heavily into this line of advice: "if a function is only called from a single place, consider inlining it."

Taking a complicated mess and breaking it into functions that are called from a single place seems better served by organising the code (maybe with duplication if needed) and writing inline comments rather than devoting a call tree to that section of code.