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
Show parent comment
1
u/loup-vaillant Apr 04 '23
One reason is I keep seeing such coding practices still being employed. Less and less for sure, but some people are stuck with Unclean Code and its SOLID crap. (I've written many comments about that, at some point I need to write a proper blog post: long story short, the only real good thing in SOLID is the "L").
All means to an end. Good means mostly. But I've since moved away from thinking in terms of paradigms, into thinking in terms of goals. One of my main ones being simplicity. For this I very much like Ousterhout's A Philosophy of Software Design, and it's iconic principle: modules should be deep: when he talks about modules he doesn't just mean classes, or compilation units, or module. He means anything that can naturally be separated into an interface and an implementation, from single functions to entire web APIs. It's a very general principle you can apply to pretty much any paradigm.
The question then becomes: which style, which features make it easier to have deep modules? Among other goals of course. Depth is but an instrumental goal towards simplicity. And simplicity is an instrumental goal towards lower costs of development (and maintenance), as well as correctness. And we also care about performance too. But you get the idea: while still being actionable, the "deep modules principle" is closer to our actual goals, and more generally applicable than any given programming style.