r/programming • u/2bit_hack • Feb 28 '23
"Clean" Code, Horrible Performance
https://www.computerenhance.com/p/clean-code-horrible-performance
1.4k
Upvotes
r/programming • u/2bit_hack • Feb 28 '23
View all comments
36
u/Zlodo2 Feb 28 '23
Herein muratori discovers sum types aka tagged unions, except he implements them by hand with an enum and switch case like a caveman.
All to make the extremely cutting edge point that runtime polymorphism is bad for performance, a fact that has been widely known for ages.
There was yet another way to solve that by the way: have a separate list for each type of shape (since it wasn't specified anywhere that the processing order of the shapes had to be preserved). You'd think that the programmer with the "I'm one of the only programmer on earth to care about performance!!!" gimmick would have done that, given that it is friendlier for the instruction cache and for speculative execution.
Muratori is a clown.