Comment on: "Clean" Code, Horrible Performance (2023)
Sure, but I don't see what this has to do with what I said? I was arguing against the parents assertion that the author's example was a strawman.For your point, what part of the design shows claims that shapes are to be added/removed by outsiders? You should design for what you know and can reasonably predict. Nothing in the article seems to claim that this problem is situated on outsiders adding their own shapes?Let's ground the example. Suppose I was writing some 2D collision checking library where these operations we're useful. Now I did Triangles, Rectangles and Circles. If I predict that
Comment on: "Clean" Code, Horrible Performance (2023)
The problem in both of these cases is to how prioritize the complexity of the domain vs. the cognitive overhead of the implementation vs. the computational complexity. If the domain is complex and best represented by modeling the domain, model the domain. If the domain is simple and the the complexity is low, make it simple. If the computational complexity is high and the domain is complex, then all solutions will be bad so minimize the suck in the best way that you know how.Occam's razor applies to all domains. Don't use confusing implementations until there are no good options left.
Comment on: "Clean" Code, Horrible Performance (2023)
Nobody argues with that. But it's helpful to know right from the title that it's the original Casey's work and not something newer.
Comment on: "Clean" Code, Horrible Performance (2023)
Sadly it is serious and in production code. (I left there 15 years ago, I suspect it isn't in production anymore)Worse, it was a giant switch, and the target system didn't have enough memory for all the code so there were different builds and the user would select which to load.There was code like case foo:
doSomething();
#ifdef build_two
doSomethingElse();
break;
case bar:
SomeThing();
#endif
MoreThings();
break;
Try to follow that mess.
Comment on: "Clean" Code, Horrible Performance (2023)
It seems like the main takeaway is that many textbook OO paradigms aren't the most optimized representations of the code. In this case, the cost is dynamic dispatch and pointer-chasing. This is a function of the Shape abstraction, but not the abstraction itself.But the argument is you're trading some of that performance optimization for maintainability. None of this is exactly news. And while I'm here ranting: I never understood why shapes are the canonical OOP example. Shapes are a closed set of types (yes I'm sure GPT-324 invented a new one) with an open set of operations. There's always goi
Comment on: "Clean" Code, Horrible Performance (2023)
I don't think beauty in code is entirely subjective. Beautiful code is like beautiful mathematics. Simple, clean, and correct by construction. All at once. There's plenty of ways to implement a graphics engine, web browser, database or OS kernel. Some of them are simpler, faster and more correct. And some approaches will inexorably lead you to a bug ridden mess.You see this clearly if you ever teach. I would give all my students the same spec. Some students submitted small, simple programs which passed all the tests with flying colours. Some students would submit huge programs which barely wor
Comment on: "Clean" Code, Horrible Performance (2023)
I'm fine with a 1k-line function if you just have that many things to do in a row without taking a breath. Breaking it up into smaller functions feels neater when you write it, but when I read it I'm essentially just macro-expanding it in my brain into the original 1k linear version, and that has some cognitive overhead (especially when they end up misordered in the file, or split across different files).I also have to think about whether there are any other areas of the code that might be calling your helpers, and whether they might break if I change the helper. Seeing everything inlined make