Earlier quoted context omitted.
> 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 fanc…
If your compilers is any good it will inline, and do a better job than you of figuring out what should be inlined. For that matter function calls are generally fast so long as the objects you copy as part of the function call are not slow to copy (which they can be). There are exceptions to the above, but in general small functions are not a problem. What is a problem is large functions. I have seen functions that we…
"Clean" Code, Horrible Performance (2023)
51–60 of 192 posts
Re: "Clean" Code, Horrible Performance (2023)
#52Earlier quoted context omitted.
> The problem with a long function is not if it has N or N+1 lines of code, it's that length code with many branching conditions is prone to be untestable and introduce non trivial bugs. Once you start to refactor, not only is it easier to parse but harder to break. This fact is known for decades now. A function with too many lines is, most likely, doing more than one thing. Functions should do one thing, be easy to…
I once saw a professional software engineer try to refactor the spaghetti code in a complex bioinfomactics project written in python. It was a complete failure. That branch was abandoned and development continued off the spaghetti. There is a reason bioinformatics has its own set of viz charts that only they use. That's my anecdote anyway, it led me to the conclusion that sometimes things are continuous spaghetti and…
It was considered too hard, most likely because the present state of the code already degenerated beyond recovery. It might be difficult, but it's never impossible.
> Mapping to terrain is always the real effort in my opinion.
Yes. The domain might be complex, and it might be possible that there are no simple ways to work within that domain. Irreducible complexity is, after all, a thing.
Re: "Clean" Code, Horrible Performance (2023)
#53Earlier quoted context omitted.
> I have seen functions that were over 60,000 lines long That can't possibly be from a serious person.
I've seen 10k+ SLOC functions written in C, and 20k SLOC functions written in Fortran, so it wouldn't surprise me if people created ones as big as bluGill describes. The C was almost always written by EEs who learned that function calls were expensive and so they minimized their use of them (this was their stated rationale, not me guessing). What amused me was that every time I tackled one of those things I'd reduce…
That, spoken by Rutger Hauer.
Re: "Clean" Code, Horrible Performance (2023)
#54Earlier quoted context omitted.
[flagged]
Even the author of clean code would fall under someone who can’t program
I am talking about knowing the idea of clean code, which doesn't include dogmatically limiting #locs in functions to an arbitrary number.
So if someone hates clean code for someone doing that, it's just dumb.
Re: "Clean" Code, Horrible Performance (2023)
#55I 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…
[flagged]
Re: "Clean" Code, Horrible Performance (2023)
#56Re: "Clean" Code, Horrible Performance (2023)
#57I'm not sure I follow the thrust of the article. The author starts off with talking about clean code, but then compares OO with procedural code. It's not the same thing, and of course we've always known that OO abstractions carry a performance penalty. Even the founders of OO (Alan Kay et al.) acknowledged the memory and compute impact, but thought it was a worthwhile tradeoff for clean abstractions in complex code-b…
Re: "Clean" Code, Horrible Performance (2023)
#58Yes, 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 t…
It's a problem chosen by the author of Clean Code. How is it a strawman? The author of the article is directly refuting the style of the problem/solution that the original author chose, and arguably demonstrated a better approach. That is not a strawman.
Re: "Clean" Code, Horrible Performance (2023)
#59I 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…