News for hackers. Stuff that matters.
Re:“Clean Code, Horrible Performance” Discussion by pkolaczk on Saturday March 11, 2023 @01:38AM (#35106066)
It is debatable if Clean Code actually improves the programmer efficiency and programs readability. I find people applying it religiously often create over-complex designs like FizzBuzz Enterprise.

Even Uncle Bob's examples are not the state of the art in readability: https://qntm.org/clean

And performance of the program vs performance of the developer is a false dichotomy. So many times I've seen a more readable, simpler code turned out to be more efficient as well. You often can have both.

Re:“Clean Code, Horrible Performance” Discussion by Apocryphon on Saturday March 11, 2023 @01:44AM (#35106089)
Clean Code led to the development of the VIPER framework, which is a crime it must answer for.
Re:“Clean Code, Horrible Performance” Discussion by fulafel on Saturday March 11, 2023 @02:56AM (#35106392)
Re:“Clean Code, Horrible Performance” Discussion by FlyingSnake on Saturday March 11, 2023 @03:04AM (#35106427)
True. VIPER was the craziest thing I had to deal with when I developed iOS.
Re:“Clean Code, Horrible Performance” Discussion by robalni on Saturday March 11, 2023 @02:30AM (#35106273)
I used to like to rewrite code that I thought was "ugly" because it was not written in the modern way or it was not very generic or whatever. I thought that doing that was often pretty easy so I thought "why has no one done this already?"

Later I realized that the fact that it was easy to change was what made it good and the changes I wanted to make to it would probably just make it more complicated.

That's the danger; good code is easy to change so it will easily get rewritten until it's not easy to change anymore.

Re:“Clean Code, Horrible Performance” Discussion by foo42 on Saturday March 11, 2023 @02:50AM (#35106367)
that last paragraph is an excellent description of the problem!
Re:“Clean Code, Horrible Performance” Discussion by jackblemming on Saturday March 11, 2023 @03:10AM (#35106453)
Strong disagree. This is something people say to sound clever. It’s not true at all. The real cause is basic entropy and complexity are always increasing. Rarely does a project manager request a feature be deleted. This is compounded by most companies having a few good programmers and mostly mediocre programmers, so the codebase will tend toward the mean over time.
Re:“Clean Code, Horrible Performance” Discussion by namaria on Saturday March 11, 2023 @03:17AM (#35106484)
Hm... Ad hominem, truism, truism, ad hominem. And not even disagreeing with the conclusion in the end...
Re:“Clean Code, Horrible Performance” Discussion by kubanczyk on Saturday March 11, 2023 @04:14AM (#35106767)
I'd say false dilemma fallacy.
Re:“Clean Code, Horrible Performance” Discussion by tpoacher on Saturday March 11, 2023 @04:06AM (#35106726)
so ... sounds like you agree?
Re:“Clean Code, Horrible Performance” Discussion by Ygg2 on Saturday March 11, 2023 @04:59AM (#35106971)
What is the alternative? Bad code?

It's exactly same as arguing you should not educate your workers. Cause they might leave. So you get only the least knowledgeable ones.

Re:“Clean Code, Horrible Performance” Discussion by lucumo on Saturday March 11, 2023 @04:23AM (#35106801)
It's really not.

Software solves business problems. Code that meets its requirements needs to be left alone. Developers just changing code because they feel like it need some coaching. They're wasting everybody's time for reasons that amount to "I like it My Way".

So, with normally performing developers, the only code that changes is the code that needs to change. Good or bad only has an influence on the cost of a change.

Re:“Clean Code, Horrible Performance” Discussion by regularfry on Saturday March 11, 2023 @04:42AM (#35106889)
That's not inconsistent with "good code will get rewritten until it's not good code." Good code that you need to change is code that can degrade as a result of that change.

Nothing to do with "just changing code because they feel like it".

Re:“Clean Code, Horrible Performance” Discussion by lucumo on Saturday March 11, 2023 @06:51AM (#35107527)
The good code will be changed after it has ceased to be good code too. And bad code can become good code in the process of changing it.

There is nothing that makes good code more or less likely to change than bad code.

Re:“Clean Code, Horrible Performance” Discussion by namaria on Saturday March 11, 2023 @03:15AM (#35106477)
>good code is easy to change so it will easily get rewritten until it's not easy to change anymore

Sounds like the 'bad currency drives good currency out of circulation' problem. Bad code drives good code out, because good code is easy to understand and change.

Re:“Clean Code, Horrible Performance” Discussion by iovrthoughtthis on Saturday March 11, 2023 @03:27AM (#35106543)
exactly
Re:“Clean Code, Horrible Performance” Discussion by Derbasti on Saturday March 11, 2023 @07:39AM (#35107822)
Without concerted effort, any easy-to-change code naturally will be replaced by hard-to-change code.
Re:“Clean Code, Horrible Performance” Discussion by tome on Saturday March 11, 2023 @08:49AM (#35108244)
> Bad code drives good code out, because good code is easy to understand and change.

I call this the Peter Principle of Programming:

"Code increases in complication to the first level where it is too complicated to understand. It then hovers around this level of complexity as developers fear to touch it, pecking away here and there to add needed features."

http://h2.jaguarpaw.co.uk/posts/peter-principle/

Re:“Clean Code, Horrible Performance” Discussion by waynesonfire on Saturday March 11, 2023 @12:13PM (#35110341)
Very cool point.

I will highlight though that I have worked with people that choose the path of least resistance regardless of complexity of the code that would need to be changed. It's as if they refuse to read code.

Re:“Clean Code, Horrible Performance” Discussion by lll-o-lll on Saturday March 11, 2023 @04:54AM (#35106944)
This is why I think the most powerful abstraction for framework with extension points is c++ template meta programming. Wait! Hear me out!

Template meta programming is an entirely separate, incredibly complex, programming language distinct from c++. The only people I have ever seen use it in production are exceptionally skilled programmers. Everyone else flees and cowers. If they try to change it it will not compile. So why is this good? Because it only allows the framework to be extended in the ways intended by the original designer. Anyone wanting to update this unholy beast will be a master programmer who’s investing significant effort. That implies the updates will be good.

Good code is easy to change. Great code is near impossible to change, but easy to extend.

Re:“Clean Code, Horrible Performance” Discussion by QuadmasterXLII on Saturday March 11, 2023 @09:09AM (#35108387)
The ITK experience
Re:“Clean Code, Horrible Performance” Discussion by jonbronson on Saturday March 11, 2023 @03:27PM (#35112333)
you just sent shivers down my spine
Re:“Clean Code, Horrible Performance” Discussion by lll-o-lll on Saturday March 11, 2023 @06:02PM (#35113691)
Shivers of excitement surely
Re:“Clean Code, Horrible Performance” Discussion by bcrosby95 on Saturday March 11, 2023 @09:35AM (#35108562)
What happens when you have new requirements that weren't envisioned by the original designers, who are no longer there? How do you unravel the design to the point where you can create a new one?
Re:“Clean Code, Horrible Performance” Discussion by lll-o-lll on Saturday March 11, 2023 @05:59PM (#35113668)
With great effort. That’s kind of my point though. It’s when you are changing the design from the originally understood “these are the ways to extend and add”, to a new paradigm, that you should be expending great effort.

In such a code base, it quickly becomes understood that if changes are required to “framework Doom” in order to achieve a new feature, the time budget will need to be large. It’s built in tech-debt prevention.

Re:“Clean Code, Horrible Performance” Discussion by simplotek on Saturday March 11, 2023 @09:41AM (#35108619)
> (...) because it was not written in the modern way or it was not very generic or whatever.

Premature generalization is a well known problem and a never-ending source of complexity. I lost count of the times I had to push back on PRs of clueless developers who felt the need to generalize one-liners that pop up twice in the whole project, and for that their proposal was to add a strategy pattern, ultimate replacing two expressions with three classes.

Re:“Clean Code, Horrible Performance” Discussion by edflsafoiewq on Saturday March 11, 2023 @09:47AM (#35108660)
> Software has a Peter Principle. If a piece of code is comprehensible, someone will extend it, so they can apply it to their own problem. If it’s incomprehensible, they’ll write their own code instead. Code tends to be extended to its level of incomprehensibility.

https://nigeltao.github.io/blog/2021/json-with-commas-commen...

Re:“Clean Code, Horrible Performance” Discussion by userbinator on Saturday March 11, 2023 @02:31AM (#35106281)
So many times I've seen a more readable, simpler code turned out to be more efficient as well.

In other words, if it's easy for the CPU to read, it's probably going to be easy for a human too. They both stumble a little on indirection and jumping around.

The other advantage of simple (macro-level, and not "one line functions" micro-level simplicity) code is that it also tends to have fewer bugs, and what bugs do appear, are also easier to find and fix.

Re:“Clean Code, Horrible Performance” Discussion by jenadine on Saturday March 11, 2023 @03:14AM (#35106472)
I disagree. Many abstraction makes it easier to read for human. Example, the first abstraction is to use functions, if/else, and loops instead of plain goto everywhere like the CPU like.

Now abstraction also have a cost that needs to be kept under control. (Some have zero costs, some have compile-time costs, some have different level of run-time costs) And of course, not every abstraction is a good one: Sometimes it can even be counter productive to hide details if these details are simpler than the abstraction itself.

In summary, it's all about trade-offs and not over-doing it.

Re:“Clean Code, Horrible Performance” Discussion by dsego on Saturday March 11, 2023 @05:44AM (#35107150)
> Many abstraction makes it easier to read for human.

Many abstractions are also conventions, just look at the js/react world. There is redux stores, mobx stores, hooks, class-based components, signals. All different abstractions with various performance and readability concerns. Someone used to one of them would say the others are not readable or maintainable. So maybe we can choose the more performant abstractions and teach them, so it becomes institutional knowledge.

Re:“Clean Code, Horrible Performance” Discussion by badpun on Saturday March 11, 2023 @12:15PM (#35110366)
> Example, the first abstraction is to use functions, if/else, and loops instead of plain goto everywhere like the CPU like.

CPU likes if/else and loops just as much as it like its gotos. If/else and loops are just conditional jump (with a comparison done before the jump), and gotos are uncoditional jumps. Both are very much machine code constructs, that's why they're in C (which is basically a syntactic sugar over assembly).

Function calls are slightly more involved, but basically also very, very low level.

Re:“Clean Code, Horrible Performance” Discussion by jenadine on Saturday March 11, 2023 @03:24PM (#35112301)
you don't write

   if (!condition) 
       goto else_;
   // some code
   goto endif;
   else_:
   // the else block
   endif:
   // More code

Same for loop. That's what we mean by "goto considered harmful".
Re:“Clean Code, Horrible Performance” Discussion by kaba0 on Saturday March 11, 2023 @03:48AM (#35106651)
So why don’t we write plain old assembly then, ad absurdum?

Here are my thoughts in a bit more detail from a previous thread: https://news.ycombinator.com/item?id=35061151

Re:“Clean Code, Horrible Performance” Discussion by fulafel on Saturday March 11, 2023 @06:51AM (#35107522)
A problem with that is that compiler technology hasn't really progressed to do big whole-program or data-layout optimizations from high level specs.

If we were closer to the model where a program would read its fixed inputs (for the run) and it would be specialized in place for the input using partial evaluation, with profile feedback for data accesses to help transforming the internal data representations to optimize storage requirement and cache access patterns, we would be much more motivated to specify many things abstractly enough to give machine representations of the code and data more freedoms.

Re:“Clean Code, Horrible Performance” Discussion by haspok on Saturday March 11, 2023 @08:41AM (#35108182)
The whole C64 scene are shaking their head in disbelief. The CPU couldn't care less about "easy readability" (whatever that even means) of your code. Ever heard of self-writing / self-modifying code? Probably an extreme example, and it can be used both ways - for performance reasons (unroll those loops!) or for abstraction (macros are your friend!).
Re:“Clean Code, Horrible Performance” Discussion by bigbillheck on Saturday March 11, 2023 @10:20AM (#35108947)
One thing you have to remember about modern CPUs is that they are not fast 6502s.
Re:“Clean Code, Horrible Performance” Discussion by wirrbel on Saturday March 11, 2023 @02:38AM (#35106310)
Robert C Martin's (who is not my uncle) Clean Code book/advice is what I would call junior programmer material. Its good to get someone started to think about better ways of writing software (albeit is hasn't aged very well).

I don't recommend it to juniors anymore because it hasn't aged well and is for my taste hyperbolic in its promises.

IMHO clean code also is more focused on code implementing "business logic" than "systems programming" for example (probably a bit tricky to actually define what the difference is between these too).

Re:“Clean Code, Horrible Performance” Discussion by readlikeasloth on Saturday March 11, 2023 @02:40AM (#35106317)
This begs the question: what do you recommend instead?
Re:“Clean Code, Horrible Performance” Discussion by markeibes on Saturday March 11, 2023 @02:44AM (#35106339)
Programming practice
Re:“Clean Code, Horrible Performance” Discussion by avereveard on Saturday March 11, 2023 @02:51AM (#35106371)
Code complete, Steve McConnell
Re:“Clean Code, Horrible Performance” Discussion by CraigJPerry on Saturday March 11, 2023 @02:59AM (#35106405)
Not the OP but HTDPv2 is a solid recommendation here
Re:“Clean Code, Horrible Performance” Discussion by asddubs on Saturday March 11, 2023 @03:04AM (#35106428)
I don't understand why you would acronym your book recommendation. Anyone this would be a useful recommendation to would not know about it already, and hence not understand the acronym.

For those wondering, "How to Design Programs"

Re:“Clean Code, Horrible Performance” Discussion by CraigJPerry on Saturday March 11, 2023 @04:19AM (#35106781)
Yeah fair comment. I guess i’ve fallen into that familiarity trap.
Re:“Clean Code, Horrible Performance” Discussion by tpoacher on Saturday March 11, 2023 @04:09AM (#35106742)
I also enjoyed the Hitchhiker's Tips for Deeper Pockets (v2).
Re:“Clean Code, Horrible Performance” Discussion by augustk on Saturday March 11, 2023 @03:24AM (#35106536)
"Code Complete" by Steve McConnell and "A Philosopy of Software Design" by John Ousterhout.
Re:“Clean Code, Horrible Performance” Discussion by raverbashing on Saturday March 11, 2023 @09:28AM (#35108501)
I second this about Code Complete. (Also I think it's at its 2nd edition, maybe 3rd?)

It's more up to the point instead of going into dogmatic diatribe

It's more evidence based (giving examples, etc)

Go for this one and Bob's your uncle! (or maybe it stops being your uncle, I guess)

Re:“Clean Code, Horrible Performance” Discussion by metaltyphoon on Saturday March 11, 2023 @01:47PM (#35111290)
> "A Philosopy of Software Design"

What a great book. I second this and add my own "The Pragmatic Programmer: 20th anniversary edition"

Re:“Clean Code, Horrible Performance” Discussion by h8hawk on Saturday March 11, 2023 @04:19AM (#35106785)
"Structure and interpretation of computer programs", its not exactly in the same category but IMO is far better. At least it doesn't make you write tones of one line,single time used functions with 400 character length name.
Re:“Clean Code, Horrible Performance” Discussion by mablopoule on Saturday March 11, 2023 @06:13AM (#35107304)
"The pragmatic Programmer" is one I would recommend.

That, and "Team Geek", in term of relationship with codes and teammates.

Re:“Clean Code, Horrible Performance” Discussion by JonChesterfield on Saturday March 11, 2023 @09:02AM (#35108338)
The pragmatic programmer is really keen on code generators. Which is the right thing to do. It's also very difficult to do in practice as the languages that are sufficiently impoverished to need external code generators are invariably bound to build tools that can't sanely deal with them.

edit: oh, and also it's hard to avoid people checking in and/or editing the generated code

Re:“Clean Code, Horrible Performance” Discussion by CraftingLinks on Saturday March 11, 2023 @02:42AM (#35106328)
Uncle Bob,the eternal noob of programming.
Re:“Clean Code, Horrible Performance” Discussion by Jensson on Saturday March 11, 2023 @04:34AM (#35106850)
Which isn't a bad thing when you write books for noobs, writing resonates more with you when it comes from one of your own.
Re:“Clean Code, Horrible Performance” Discussion by goto11 on Saturday March 11, 2023 @04:22AM (#35106792)
As an old-timer it is easy to forget that we all started as beginners and had to learn all the things which now are second nature to us. At some point the material which is valuable to a beginner seems trite, obvious and simplistic to a senior.
Re:“Clean Code, Horrible Performance” Discussion by regularfry on Saturday March 11, 2023 @04:46AM (#35106910)
I am not fond of Clean Code, but I am fond of Clean Architecture. It's a much smaller set of ideas, for a start.
Re:“Clean Code, Horrible Performance” Discussion by amptorn on Saturday March 11, 2023 @03:32PM (#35112399)
I gave up on Clean Architecture after about one chapter. There's a section where he's graphing the number of lines of code in a hypothetical company's codebase over time - it grows rapidly at first and then it levels off, and he points at this like it means anything, specifically like it's a bad thing and it means the software has become difficult to work in. Also this isn't a line chart, it's a bar chart, and the X axis isn't time, it's unlabeled - eventually, in the text, you find that there's one bar per major release of the software, if that tells you anything about how retro this conception of software development is. Another bar chart shows the number of developers growing rapidly, as if that means anything either... It was just baffling.
Re:“Clean Code, Horrible Performance” Discussion by whstl on Saturday March 18, 2023 @08:07AM (#35208391)
I personally find that those two videos are much better at conveying the foundational knowledge needed to invent and understand something like Clean Architecture than the book itself:

https://www.destroyallsoftware.com/screencasts/catalog/funct...

https://www.destroyallsoftware.com/talks/boundaries

It seems unrelated in the surface, but I feel like they explain the "why" of a software architecture in a much simpler way and without the prescriptive and hand-wavy "trust me" nature of most software architecture books.

Re:“Clean Code, Horrible Performance” Discussion by kgeist on Saturday March 11, 2023 @06:46AM (#35107482)
Just yesterday, when discussing our company's grades, someone joked that the difference between a junior and a senior developer is that a junior developer should learn to know when to use OOP/abstractions while a senior developer should learn to recognize when OOP/abstractions are to be avoided.
Re:“Clean Code, Horrible Performance” Discussion by giraffe_lady on Saturday March 11, 2023 @11:54AM (#35110128)
Used to be a similar joke in frontend a few years ago when css was at its complexity peak. Where the progression is junior: "I'll just use bootstrap", mid: "I'll write my own css custom tailored to the project", senior: "I'll just use bootstrap."

I also think some of this... attitude? learning? is what go is trying to activate/take advantage of. Everywhere I've worked has had some monstrously experienced senior dev who could easily crack out a solution to a problem of any difficulty but who refuses to use any abstraction more sophisticated than a for loop.

Go says you don't need anything more sophisticated than a for loop, in fact you can't have anything more sophisticated than a for loop. I guess I'm not there yet but it definitely seems suspicious that the people I know who are most into go are very early in their careers or deeply experienced.

Re:“Clean Code, Horrible Performance” Discussion by whstl on Saturday March 18, 2023 @07:56AM (#35208313)
I agree, but I would extend it a bit:

For a junior the answer is more "I'll just use bootstrap and customize as much as needed".

While for a senior it's more in line with "I'll just use bootstrap, but you bet I will be on the designer's ass if they ask to customize stuff where it's not necessary."

There is a reason the mid-level developer wanted to write custom CSS. And the reason is that they didn't have the political capital to make bootstrap alone work in a way that is good for the company.

Re:“Clean Code, Horrible Performance” Discussion by oweiler on Saturday March 11, 2023 @02:41AM (#35106325)
Not only is it debatable, you never see any type of evidence. And how would you measure it?
Re:“Clean Code, Horrible Performance” Discussion by fulafel on Saturday March 11, 2023 @02:49AM (#35106359)
Interesting that he now prefers Clojure, where rules like "function names should be verbs" take a 180 and become don'ts.
Re:“Clean Code, Horrible Performance” Discussion by goto11 on Saturday March 11, 2023 @03:41AM (#35106609)
> I find people applying it religiously often create over-complex designs like FizzBuzz Enterprise.

To be fair, this can be said about any technique. Lots of bad code results from people taking a reasonable principle and applying it religiously rather than judiciously.

Re:“Clean Code, Horrible Performance” Discussion by Ygg2 on Saturday March 11, 2023 @05:06AM (#35106996)
On the other side of taking Muratori advice too far, is the story of Mel. Or to be more precise the guy that comes after Mel.

You have a ball of highly optimized mud, that quantum collapses if you glance at it too harshly, and we need it to be USB compatible. By Tuesday. Good luck!

Re:“Clean Code, Horrible Performance” Discussion by tpoacher on Saturday March 11, 2023 @04:04AM (#35106721)
Clean code is defined as code that improves programmer efficiency and program readability, eschews premature optimisation by optimising for simplicity, makes code less complex and objectively better by optimising for readability, allowing virtually anyone to safely and easily change it when really needed.

So you're actually a clean code proponent.

As is usually the case with such debates, it is a debate of differing definitions masquerading as a debate of differing arguments.

Re:“Clean Code, Horrible Performance” Discussion by josephg on Saturday March 11, 2023 @04:11AM (#35106751)
> Clean code is defined as code that improves programmer efficiency and program readability, eschews premature optimisation by optimising for simplicity, makes code less complex and objectively better by optimising for readability, allowing virtually anyone to safely and easily change it when really needed.

I think plenty of people love clean code. I love programmer efficiency and readability. But there's clean code and "Clean Code". Some of the code examples from Robert C. Martin's Clean Code book are absolutely atrocious. I would be horrified to find anything so unnecessarily abstracted and overcomplicated in my codebase.

Its precisely because I'm all for readability and programmer efficiency that I find the recommendations in "Clean Code" so bizarre and abhorrent.

Re:“Clean Code, Horrible Performance” Discussion by dsego on Saturday March 11, 2023 @05:55AM (#35107213)
His examples use class state as faux-global state and dozens of small one-line methods that "do one thing", but don't really, since they operate on this object state. In the end, it makes it difficult to follow the logic flow, since you have to jump around from one small method to the other to understand what's happening. And clear understandable method naming is of limited help, so it turns into this ravioli code anti-pattern, clean on the surface, but semantically all tangled up.
Re:“Clean Code, Horrible Performance” Discussion by pkolaczk on Saturday March 11, 2023 @04:06AM (#35106728)
Ok. Fair enough. I just find that what Uncle Bob calls clean code is often not clean code for me. E.g. preferring inheritance over switch is less readable. Flexibility/extensibility and readability are different things.
Re:“Clean Code, Horrible Performance” Discussion by goto11 on Saturday March 11, 2023 @04:13AM (#35106764)
> E.g. preferring inheritance over switch is less readable.

Surely this depends on the context? If you have a many different classes it tend to lead to cleaner code if you encapsulate the class-specific logic with the class definition rather than intermingled in multiple giant switch statements. In particular you can add new classes without making the rest of the code more complex.

Of course there are cases where a switch is the right choice.

Re:“Clean Code, Horrible Performance” Discussion by kubanczyk on Saturday March 11, 2023 @04:35AM (#35106856)
> Surely this depends on the context?

Yes, it depends on the context. In this case the context is the switch statement described in the https://www.computerenhance.com/p/clean-code-horrible-perfor.... Too bad TFA never mentions it explicitly (other than in the title and in the video). Recently it generated a heated discussion around here.

Re:“Clean Code, Horrible Performance” Discussion by pkolaczk on Saturday March 11, 2023 @04:22AM (#35106797)
Switch statements don't have to be giant. Hint: you can still extract each branch to a separate function / module. But what is more readable about them is the control flow: the condition is explicit and all targets are easy to find. A codebase using switches/ifs and function calls can be easily navigated with ctrl-click in most IDEs. A codebase relying heavily on interfaces and inheritance cannot.
Re:“Clean Code, Horrible Performance” Discussion by laserlight on Saturday March 11, 2023 @04:40AM (#35106880)
If you aren't going to use polymorphism to vary behavior, but depend on conditionals, what do you use classes for? Just for hierarchical data encapsulation?
Re:“Clean Code, Horrible Performance” Discussion by pkolaczk on Saturday March 11, 2023 @05:29AM (#35107094)
Surprise: I don't use classes. Rust doesn't have them. :P
Re:“Clean Code, Horrible Performance” Discussion by laserlight on Saturday March 11, 2023 @06:42AM (#35107463)
So, you’ve been arguing for using switch statements, instead of Clean Code’s suggestion of using object-oriented polymorphism, in a context where polymorphism doesn’t exist?
Re:“Clean Code, Horrible Performance” Discussion by pkolaczk on Saturday March 11, 2023 @07:34AM (#35107779)
Not at all. Not having classes is not the same as not having polymorphism. Rust supports polymorphism just fine (and one could argue its support for polymorphism is actually much more advanced than that of Java's; but that's not enough reason to use it everywhere).
Re:“Clean Code, Horrible Performance” Discussion by whstl on Saturday March 18, 2023 @08:45AM (#35208638)
The greatest trick OOP ever pulled was convincing the world that polymorphism didn't exist outside OOP.
Re:“Clean Code, Horrible Performance” Discussion by bart_spoon on Saturday March 11, 2023 @08:05PM (#35115063)
How are structs in Rust any different than classes?
Re:“Clean Code, Horrible Performance” Discussion by hdhrufjdi on Sunday March 12, 2023 @01:14AM (#35117276)
Behavior and data is more separated

A struct only contains data, however you e.g. can define methods on it or implement traits for it No inheritance.

Re:“Clean Code, Horrible Performance” Discussion by bart_spoon on Sunday March 12, 2023 @09:21AM (#35119756)
They don’t only contain data though, you can define methods as you said. Yes, there is no-inheritance, but they contain data, maintain state, and allow for defined methods. 90% of the time people are talking about classes, they are talking about that.
Re:“Clean Code, Horrible Performance” Discussion by goto11 on Sunday March 12, 2023 @05:30AM (#35118262)
I use multiple languages and I always consider the context of programming advice. I recommend a broadened perspective.
Re:“Clean Code, Horrible Performance” Discussion by dsego on Saturday March 11, 2023 @06:21AM (#35107347)
Afaik, data-oriented approach doesn't use classes to encapsulate behavior.
Re:“Clean Code, Horrible Performance” Discussion by goto11 on Saturday March 11, 2023 @04:34AM (#35106853)
So you are saying context doesn't matter, switch is always better?
Re:“Clean Code, Horrible Performance” Discussion by pkolaczk on Saturday March 11, 2023 @05:36AM (#35107121)
If we talk about readability - it is hard to think of a situation when inheritance would be better - it adds an indirection, it hides what's really going on, and at the end of the day the code is also longer and more complex.

However it has some other uses, e.g. when you really want to support adding new cases without modifying the code, e.g when doing a library, you need some kind of polymorphism.

So basically - it is not that abstractions/indirections are inherently bad, but they come at a cognitive cost. And it depends on the context if this cost is justifiable.

Re:“Clean Code, Horrible Performance” Discussion by mejutoco on Saturday March 11, 2023 @09:31AM (#35108529)
Agree. Inheritance is a code smell. And clean code does not smell :)
Re:“Clean Code, Horrible Performance” Discussion by jdlshore on Saturday March 11, 2023 @01:40PM (#35111218)
Polymorphism is useful when switch statements are repeated, as a way of eliminating that duplication, not when there’s a single well-encapsulated switch statement.
Re:“Clean Code, Horrible Performance” Discussion by dsego on Saturday March 11, 2023 @04:27AM (#35106819)
I've seen examples of FizzBuzz Enterprise in practice, eg a small algorithmic challenge that reads in some data and finds a value was split into several files, one class to read the data, one class to run the algorithm, one file to print out the results, etc etc. What was supposed to be one function with less than 50 lines turned into a multi-class multi-file monstrosity. The Java coder doing it couldn't imagine doing it any other way.
Re:“Clean Code, Horrible Performance” Discussion by ketzu on Saturday March 11, 2023 @11:19AM (#35109659)
> a small algorithmic challenge

For me that depends on the context:

* A challenge for an interview? No wonder people try to insert structure as if it were a bigger project.

* A challenge for a contest? Probably not a good solultion for most point systems.

* A challenge for fun on hackerrank or LC? Whatever you feel comfortable with works.

For structuring a larger system, separating data ingestion, data output and algorithm to work on the data, seems like a fairly entry level separation.

Re:“Clean Code, Horrible Performance” Discussion by SPBS on Saturday March 11, 2023 @05:53AM (#35107201)
Thanks, this comment accurately captures my discomfort when reading the parts where Uncle Bob was talking. He consistently portrays Clean Code as a programmer friendliness vs processor speed tradeoff, while my impression of Clean Code has never been that it’s slow and programmer friendly, but full of overengineered design patterns that are horrible to read.“Premature optimisation in code flexibility” is a really succinct way of putting it.
Re:“Clean Code, Horrible Performance” Discussion by whstl on Saturday March 18, 2023 @08:09AM (#35208401)
I personally find it full of rules that make sense in isolation and can make your code look pretty when you're a solo developer, but are actively making it more difficult to make the program understandable and flexible in the long way.
Re:“Clean Code, Horrible Performance” Discussion by osigurdson on Saturday March 11, 2023 @10:03AM (#35108773)
I think we would be far better off in analyzing codebases that are considered well done and then try to reverse engineer some good practices out of these. Uncle Bob et all are just riffing on tiny sample projects that they work on in between speaking engagements. I’d trust the opinions of these types of people a lot more if they actually had achieved anything other than writing books and talking.
Re:“Clean Code, Horrible Performance” Discussion by lll-o-lll on Saturday March 11, 2023 @04:34PM (#35112967)
Your words are harsh, but they are true. Our industry has been a train wreck of mediocre ideas capturing mindshare and spread with religious fervour. Money, damned filthy lucre, is of course the reason behind this.

I don’t blame the players, but I do wish there was some way to inoculate the herd. Perhaps we need a proper religious tradition. Robes would at least make it fun.

Re:“Clean Code, Horrible Performance” Discussion by osigurdson on Saturday March 11, 2023 @04:52PM (#35113163)
>> Our industry has been a train wreck of mediocre ideas capturing mindshare and spread with religious fervour

This is a great comment. Quotable even.

Re:“Clean Code, Horrible Performance” Discussion by userbinator on Saturday March 11, 2023 @08:15PM (#35115141)
Snake-oil salesmen have always existed in one form or another.

OOP was pushed very strongly in the 90s, for example, and people promising to create massive increases in productivity by providing consulting services for "OOP-ifying" code probably made plenty of $$$ off that fad.

Re:“Clean Code, Horrible Performance” Discussion by gofreddygo on Saturday March 11, 2023 @11:06AM (#35109476)
I think of this as a cross spectrum (terrible, good enough, well done, overdone)

I've seen less production code and more discussions on code that focusses on opposite ends.

terrible readability and maintainability with extreme performance.

v/s.

terrible performance with overdone "design" abstractions.

OTOH, I've seen lot of production code that has good enough design, with well done perf and vice verse.

Not much talk about that stuff.

Re:“Clean Code, Horrible Performance” Discussion by xnx on Saturday March 11, 2023 @11:06AM (#35109478)
Like "Reduce. Reuse. Recycle." The logic behind "Make It Work. Make It Right. Make It Fast." is very deliberate.
Re:“Clean Code, Horrible Performance” Discussion by z3t4 on Saturday March 11, 2023 @11:19AM (#35109647)
I want to add reusability and removability. If I for example write some code that connects to a SMTP server to send an e-mail, I probably will re-use it in other places, even in other programs, so the code can't depend on global functions. The code should be independent. Then it also becomes removable and replaceable.
Re:“Clean Code, Horrible Performance” Discussion by Gibbon1 on Saturday March 11, 2023 @05:23PM (#35113412)
> Clean Code is mostly a premature optimization in code flexibility > in practice the code has to be significantly changed/rewritten anyway when a business requirement change appears.

Tying these two together. Clean Code doesn't distinguish between framework code and business logic code. Or more you should write the latter like the former. The problem is writing framework code is hard to do well. It needs to be well thought out, bullet proof, and importantly well documented. That takes a lot of time and effort and running the code under a number of different use cases.

One is better off writing business logic as straight forward and goal directed as possible.

Re:“Clean Code, Horrible Performance” Discussion by whstl on Saturday March 18, 2023 @08:43AM (#35208627)
That's interesting, this is the first time I've heard this critique, and I totally agree.

The coding culture around Clean Code seems to put a lot of effort into "building frameworks on top of frameworks" without really admitting it, and the "framework-y bits" are intertwined with business logic, like exposed piping in a building. But business logic should look more like Golang instead.

Re:“Clean Code, Horrible Performance” Discussion by Spivak on Sunday March 12, 2023 @12:21AM (#35116952)
This is pretty much my soapbox about DRY. Code is like clay, once it dries it’s not malleable anymore. Components that copy/paste but in doing so are self-contained can be fearlessly changed.

And above a certain size dry works against you because when making changes to component A that requires a slight modification of the behavior or component Q deep in the call stack is so painful because the blast radius is huge. Dry codebases end up slowly accumulating more and more effectively read-only code that makes implementing non-trivial changes require increasing amounts of cleverness until development slows.

I think the more general principle is more to do with code directionality and framework vs library but the motivation to franken-framework your code always seems to be dry.

Re:“Clean Code, Horrible Performance” Discussion by darepublic on Sunday March 12, 2023 @10:50AM (#35120661)
Having worked with very non dry code where each instance has slight variations but none of the commonalities are captured.. I have to say it can cause a lot of bugs and a lot of headache to maintain.