Live data from Hacker News

"Clean" Code, Horrible Performance (2023)

computerenhance.com

11–20 of 192 posts

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

#11
post #9
post #5

I'd say Clean Code is teaching many bad-practices. Too many to be recommended.

eh, when I read it as a newbie it was really helpful. still had to make my own experiences and judgments, but overall I think reading it made me a better programmer

at bast it makes to better at "Clean(TM) OOP code".

programming in general is waaaaaay bigger than what the book covers.

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

#12
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 the actual code. This is the point where most people come to hate Clean Code.

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

#13
Ok now add a Path shape that has to calculate the area of a polygon with arbitrary complexity.

Consider how the workload is now dominated by the core task of actually calculating the area, reducing the impact of struct usage.

Consider the diffs required to make this change.

It's not like Clean Code should be taken as gospel but this micro-benchmark is not a realistic example of what CC is trying to solve.

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

#14
post #3

Earlier quoted context omitted.

Still true today.

I don't think it was true even in 2023. This sounds like tackling the problems of C++ in the early 2000s. 1. Casey Muratori also that DRY shouldn't doesn't have to result in non-performant code. 2. Smaller functions, functions that do one-thing: Modern compiler can inline those. There are some edge cases where inlining may make less efficient use of states and loops but I don't think that's a main problem nowadays. I…

This reads like contrarianism to me, like you have to oppose the article because you just do (maybe you dislike Casey). There's plenty of code written the way Casey disagrees with.

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

#16
post #11
post #9

Earlier quoted context omitted.

eh, when I read it as a newbie it was really helpful. still had to make my own experiences and judgments, but overall I think reading it made me a better programmer

at bast it makes to better at "Clean(TM) OOP code". programming in general is waaaaaay bigger than what the book covers.

> programming in general is waaaaaay bigger than what the book covers.

It's way bigger than any book covers. Clean Code has some useful things, but if anyone actually reads chapter 1 they'd see that Martin even addresses the idea that you should not just read Clean Code and use it alone, or even entirely. It's a collection of one person's judgements (some good, some bad), just like all the other books like it.

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

#17
post #13

Ok now add a Path shape that has to calculate the area of a polygon with arbitrary complexity. Consider how the workload is now dominated by the core task of actually calculating the area, reducing the impact of struct usage. Consider the diffs required to make this change. It's not like Clean Code should be taken as gospel but this micro-benchmark is not a realistic example of what CC is trying to solve.

In that case, you'd branch into a separate function/block that runs the calculation. Sure, it's slower than a simple array index to find a coefficient, but you're only incurring that cost when you actually need it and it's still much faster than using polymorphism everywhere instead.

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

#18

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…

You mean people come to hate code reviews.

If you don't use those rules, you'll argue about something else in the code reviews. Likely something even more ambigous that wasn't explicitly written down for everyone as a baseline.

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

#19
Yes, a toy problem only needs a simple implementation. This is a straw man. And I don't even like Robert Martin's Clean Code, but the author is not addressing where this style actually provides benefits. When you're updating 23 if-statements because you had to add support for some new business workflow, you'll wish you had a conceptual entity that encapsulated the operations on the type of workflows so you just had to implement them in one place.

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

#20
post #5

I'd say Clean Code is teaching many bad-practices. Too many to be recommended.

> Functions should be small + Functions should do one thing

This is often a trap for performance. Sure, it looks nice on a screen but calling a function to return a variable is usually epic waste of performance unless compiler will save you by inlining the function into your code or architecture you are using has a magic instruction for that (call vs fcall - which compiler has to recognize and use) which is just fancy "goto there, mov r1 <- *var, goto back"

Post reply on HN