Live data from Hacker News

“Clean” code, horrible performance

computerenhance.com

61–70 of 932 posts

Re: “Clean” code, horrible performance

#61
I don't think there is a contradiction or surprising point here.

At least my understanding of the case for clean code is that developer time is a significantly more expensive resource than compute, therefore write code in a way which optimises for developers understanding and changing it, even at the expense of making it slower to run (within sensible limits etc etc).

Re: “Clean” code, horrible performance

#62
TL;DR:

"Game developer optimizes code for execution as opposed to readability that 'clean-code' people suggest".

There are few considerations:

- most code is not CPU bound so his claims that you are eroding progress because you are not optimizing for CPU efficiency is baseless

- writing readable code is more important than writing super optimal code (few exceptions: gaming is one)

- using enums vs OOP is not changing the readability at least to me

I think we can have fast and readable code without following the 'clean-code' principles and at the end it does not matter how much gain we have CPU cycle-wise.

Re: “Clean” code, horrible performance

#63
post #11

The problem with the contemporary "clean code" concept is that the narrative that performance and efficiency don't matter has been pushed down the throat of all programmers. Re-usability, OOP concepts or pure functional style, design patterns, TDD or XP methodologies are the only things that matter... And if you use them you will write "clean code". Even worse, the more concepts and abstractions you apply to your cod…

> the narrative that performance and efficiency don't matter

That was the case during the 90s and the first decade of the 2000. Just wait for Moore's Law to kick in and in 18 months your code will get faster by an order of magnitude for free.

Re: “Clean” code, horrible performance

#64

This seems more like an argument against the object oriented model of C++ than anything else. Would have been more interesting if the performance was compared to languages like Rust.

My key learning is the importance of balancing performance and code cleanliness instead of blindly adhering to clean code principles.

If you optimize for readability performance would suffer. If you optimize for performance readability will suffer.

Casey prizes performance over everything else.

Re: “Clean” code, horrible performance

#65
post #11

The problem with the contemporary "clean code" concept is that the narrative that performance and efficiency don't matter has been pushed down the throat of all programmers. Re-usability, OOP concepts or pure functional style, design patterns, TDD or XP methodologies are the only things that matter... And if you use them you will write "clean code". Even worse, the more concepts and abstractions you apply to your cod…

Strangely enough, even in this video, everyone notice how you're taken to make tradeoffs between coherence and cleanliness vs performance-oriented code in langs like C++, while the Clean Code book was exemplified in Java (so most of performance is shoved in JVM code) and SICP was in Scheme (which is interpreted, or transpiled to C where you can optimize, or has a VM/JIT underneath).

I vaguely smell the language of choice has something to do with that, and C++ would benefit more from data-oriented design than from literate OOP or functional programming patterns took from very very different programming ethoses (the programming language is an interface to something else)

Re: “Clean” code, horrible performance

#66

I don't think there is a contradiction or surprising point here. At least my understanding of the case for clean code is that developer time is a significantly more expensive resource than compute, therefore write code in a way which optimises for developers understanding and changing it, even at the expense of making it slower to run (within sensible limits etc etc).

Externalised cost on the environment will hopefully one day be addressed.

Re: “Clean” code, horrible performance

#67
post #14

Really enjoyed watching some guy Breathlessly discover data oriented design https://en.wikipedia.org/wiki/Data-oriented_design there's nothing novel in this video, really nothing to do with clean code. This is same sort of thing you see with pure python versus numpy

You could spend 2 minutes looking up who you are talking about.

This video from 2015 where Casey is interviewing Mike Acton: https://www.youtube.com/watch?v=qWJpI2adCcs

Also this course where he specifically talks about Numpy and pure Python: https://www.computerenhance.com/p/python-revisited

Re: “Clean” code, horrible performance

#68
post #56

This seems more like an argument against the object oriented model of C++ than anything else. Would have been more interesting if the performance was compared to languages like Rust.

I think it could be ok to have a link every once in a while that doesn't talk about rust.

We're talking about C++ and performance, no way nobody would mention rust :P

Re: “Clean” code, horrible performance

#69
post #11

The problem with the contemporary "clean code" concept is that the narrative that performance and efficiency don't matter has been pushed down the throat of all programmers. Re-usability, OOP concepts or pure functional style, design patterns, TDD or XP methodologies are the only things that matter... And if you use them you will write "clean code". Even worse, the more concepts and abstractions you apply to your cod…

At least in the majority of places I worked at, people cared about readability and maintainability rather than just some abstract notion of "clean code". And perhaps I was lucky, but typically readability and maintainability are orthogonal to performance and efficiency. Sometimes readable will have optimal performance, sometimes not. Then it becomes a matter of tradeoffs.

Same here. We had coding guidelines, not rules.

The first entry even stated that they were guidelines and if you have a valid reason to deviate: discuss it and you'll get an exception.

The discussion thing was mainly for new coders. We had a library part of the code that was used by many programs. Optimizing parts of it for their use case, could make it unusable for the others who used it.

Communication is key. If you discuss, before implementing it, why you're making certain design decisions then everything goes a lot smoother. If there are objections, keep in mind that the worst case isn't throwing away your design and starting over. The worst case is implementing it and screwing over your fellow coders.

Re: “Clean” code, horrible performance

#70

I don't think there is a contradiction or surprising point here. At least my understanding of the case for clean code is that developer time is a significantly more expensive resource than compute, therefore write code in a way which optimises for developers understanding and changing it, even at the expense of making it slower to run (within sensible limits etc etc).

Externalised cost on the environment will hopefully one day be addressed.

Not to mention the users. For all the bullshit the marketing departments of every company spew about valuing their customers, software companies don't really give a damn about the many person-hours of users' lives they waste to save a person-minute of dev time.
Post reply on HN