Re:Linear code is more readable
by userbinator on Friday September 15, 2023 @12:54AM
(#37518611)
It's more readable to the CPU too.
Deeply nested code, especially with many functions that are called once, is really horrible to debug.
Extract functions when you see obvious repetition, not just to appease some dogmatic abstraction goal. Incidentally, this also helps the CPU (cache locality).
Along the same lines, I'd rather have a directory with several dozen source files than several dozen nested directories that may contain only one or two files each.
Re:Linear code is more readable
by realrains on Friday September 15, 2023 @04:23AM
(#37520068)
I don't think the issue is about which code is more readable, but whether it's efficient for the CPU or the computer. Modern compilers optimize more than we think in production builds.
Deeply nested code, especially with many functions that are called once, is really horrible to debug.
Extract functions when you see obvious repetition, not just to appease some dogmatic abstraction goal. Incidentally, this also helps the CPU (cache locality).
Along the same lines, I'd rather have a directory with several dozen source files than several dozen nested directories that may contain only one or two files each.