Live data from Hacker News

"Clean" Code, Horrible Performance (2023)

computerenhance.com

131–140 of 192 posts

Re: "Clean" Code, Horrible Performance (2023)

#131

This is Muratori showing he's a solo programmer who has only ever worked on relative small, simple software that runs on a single machine.

He worked on the Granny animation system at Rad Game Tools. It's shipped in over 5200 games[1] and targets all the major game dev platforms.

[1] https://www.radgametools.com/granny/customers.html

Re: "Clean" Code, Horrible Performance (2023)

#132

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 nev…

> In this case, the cost is dynamic dispatch and pointer-chasing. To sharpen your statement, the cost is missing the CPU caches, which is often caused by failing to pool allocations and reading indirectly. > But the argument is you're trading some of that performance optimization for maintainability. Right, but exactly how much? I would argue "very OOP" design styles neuter your ability to optimize the system, and so…

Well said. And when you put it that way (we have not figured out how to retain control over the computer in the face of these abstractions), I almost laughed out loud because of how true it is. Some of the worst, most confusing codebases I have touched are full of abstractions that require me to have 5 tabs open at once in my IDE to understand what is going on. The type of codebase that ends up being a sales pitch for multi-monitor setups.

Re: "Clean" Code, Horrible Performance (2023)

#133

I consider Clean Code to be in the category of books/styles that is helpful for early developers who need some structure, but harmful to late-stage developers who adopt it as dogma. On a long enough career path, eventually you will run into one Clean Code zealot who carries an air of superiority and nit picks every PR over things like a function having more than an arbitrary number of lines in it instead of reviewing…

Sometimes it feels like the more someone has memorized all the little acronyms and jargon and principals around programming the worse they are as an engineer.

I worked with a guy who would constantly drop niche jargon and quotes from famous engineers and then kind of smugly look at you. He could not write a function without proudly saying what principals it was following. He was a horrible programmer, ended up getting laid off.

Re: "Clean" Code, Horrible Performance (2023)

#134

I consider Clean Code to be in the category of books/styles that is helpful for early developers who need some structure, but harmful to late-stage developers who adopt it as dogma. On a long enough career path, eventually you will run into one Clean Code zealot who carries an air of superiority and nit picks every PR over things like a function having more than an arbitrary number of lines in it instead of reviewing…

I think you’ve missed the point of clean code if this is your gripe with it. Every time you over scope a function signature, because you want to handle that other case, you add mental tax to the next person. This accumulates, burns time, and now confuses agents, which is time and tokens ($). No one wants to work with a dogmatic individual but I’d rather a nit picker than a human or agent slop machine.

Okay, but Clean Code* would advocate you extract that function to its own class with a new abstraction and it would ultimately wind up way more complicated than the extra params in a function signature

Re: "Clean" Code, Horrible Performance (2023)

#135
post #92

Earlier quoted context omitted.

> but harmful to late-stage developers who adopt it as dogma. Even Robert Martin, very often in his videos and blogs, espouses "engineering judgment" and is quite fine abandoning advice in his book when the situation calls for it. If performance is important and clean code is impacting it, he won't object to your breaking the rules. It's mostly with his TDD evangelism that he goes (a little) crazy.

I just think - in the book at least - he has really bad taste. The examples are full of “spooky action at a distance”. He writes the exact sort of class functions that make a lot of OO terrible to work with, where a function that should be pure has some weird hidden side effects. Code like that is really difficult to reason about and impossible to reuse safely. Somewhat ironic, given what he preaches in the rest of t…

your opinion is no less valid than his. you see the problem if you use the word clean or beautiful. its opinions. so people will debate it till no end. it matters nothing at all.

Re: "Clean" Code, Horrible Performance (2023)

#136

Earlier quoted context omitted.

No, it's a false dichotomy. When working on large applications, by far the single most important factor in performance is having simple and understandable code. Understandable but slow code can be fixed. Incomprehensible code can't, so it either stays slow or gets worked around with caching/async processing/etc. If you want fast software, you should write the simplest thing that isn't obviously stupidly slow, then me…

This is only true up to some point of skill & complexity. Hotspot optimisation only takes you so far. Eventually you can end up with a program that is fast everywhere but which is still somehow slow at the macro level. Like LLVM. Truly fast software is made by thinking about data flow from the start. If you use the right data structures, the code takes care of itself. But this is far beyond Clean Code. The examples i…

This. I've spent a good chunk of my career on performance work and this idea that you can hotspot optimize stuff after the fact is utterly wrong and the reason why so much of your software sucks battery and runs like crap.

Clean code like approaches have a very real cost for users (even in languages with good optimizers) and is usually unfixable after the fact.

Re: "Clean" Code, Horrible Performance (2023)

#137
its a bigger problem of class based abstractions...cpu thinks in terms of arrays and lanes and indexes thats literally what a pointer is...when you try and abstract that away it in the wrong way that compiler cant understand, it creates overhead. but i think this is overall for all patterns in programming classrs are just so low level people take it for dogma and are appalled that something so standard is anti pattern

Re: "Clean" Code, Horrible Performance (2023)

#138

Earlier quoted context omitted.

I just think - in the book at least - he has really bad taste. The examples are full of “spooky action at a distance”. He writes the exact sort of class functions that make a lot of OO terrible to work with, where a function that should be pure has some weird hidden side effects. Code like that is really difficult to reason about and impossible to reuse safely. Somewhat ironic, given what he preaches in the rest of t…

The ugly reality is consultants like Martin have little production coding experience. Martin has posts going back to the early 90s showing he had little understanding of how software teams work and deliver value. From what I have seen, his ideas were formed in a vacuum divorced from real coding. You can see it in the small amounts of open source he has released. The kind of guy who will always prefer 50 classes to 5.…

Those who can't do, teach.

Re: "Clean" Code, Horrible Performance (2023)

#139

I consider Clean Code to be in the category of books/styles that is helpful for early developers who need some structure, but harmful to late-stage developers who adopt it as dogma. On a long enough career path, eventually you will run into one Clean Code zealot who carries an air of superiority and nit picks every PR over things like a function having more than an arbitrary number of lines in it instead of reviewing…

> I consider Clean Code to be in the category of books/styles that is helpful for early developers who need some structure Clean Code is unhelpful to beginners too, though: misuse of industry-standard terms, shunning of comments in favor of tiny functions with long names, shunning function arguments in favor of mutating state, polymorphism obsession, etc. So much of the concrete advice the book gives is just plain ba…

The tone really is genius marketing though. Like who wants to be a "dirty" coder? Reminds me of that quote about the etymology of dynamic programming:

> it's impossible to use the word dynamic in a pejorative sense. Try thinking of some combination that will possibly give it a pejorative meaning. It's impossible. Thus, I thought dynamic programming was a good name. It was something not even a Congressman could object to. So I used it as an umbrella for my activities.

Post reply on HN