Re:“Clean Code, Horrible Performance” Discussion
by badpun on Saturday March 11, 2023 @12:15PM
(#35110366)
> Example, the first abstraction is to use functions, if/else, and loops instead of plain goto everywhere like the CPU like.
CPU likes if/else and loops just as much as it like its gotos. If/else and loops are just conditional jump (with a comparison done before the jump), and gotos are uncoditional jumps. Both are very much machine code constructs, that's why they're in C (which is basically a syntactic sugar over assembly).
Function calls are slightly more involved, but basically also very, very low level.
CPU likes if/else and loops just as much as it like its gotos. If/else and loops are just conditional jump (with a comparison done before the jump), and gotos are uncoditional jumps. Both are very much machine code constructs, that's why they're in C (which is basically a syntactic sugar over assembly).
Function calls are slightly more involved, but basically also very, very low level.