News for hackers. Stuff that matters.
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.