News for hackers. Stuff that matters.
Re:Case against OOP is understated, not overstated (2020) by taurath on Thursday February 10, 2022 @06:58PM (#30294686)
> This is primarily because of inheritance, which seems counter-intuitive

I agree that inheritance creates a lot more problems, but the usages of non-static methods and internal state even in classes with no usage of inheritance can feel just as bad, when you have a high level method utilizing instantiated objects. Internal state as a whole can be avoided fairly often

Re:Case against OOP is understated, not overstated (2020) by jshen on Thursday February 10, 2022 @08:27PM (#30295584)
I don’t see much difference between

    some_state.do_stuff()
    do_stuff(some_state)
Re:Case against OOP is understated, not overstated (2020) by lolinder on Thursday February 10, 2022 @09:17PM (#30296009)
They're just different syntaxes for the same thing. I think what OP is driving at isn't the syntactic difference but making immutable what doesn't need to be mutable. You could do that with either syntax.
Re:Case against OOP is understated, not overstated (2020) by jshen on Friday February 11, 2022 @12:06AM (#30297232)
Yes, but I think the person he/she was replying to is right, the biggest problem is inheritance.
Re:Case against OOP is understated, not overstated (2020) by rbanffy on Friday February 11, 2022 @06:54AM (#30300337)
The second one scares me. It implies some_state is mutated (or not, we may just be logging something) by the do_stuff function while the first makes it very clear that some_state is in charge of doing stuff and that the implementation is aware of how some_state is implemented itself.

OTOH, the second one would be much better (and imply immutability) if it were written as

  new_state = do_stuff(some_state)
But it'd also allocate a new state.
Re:Case against OOP is understated, not overstated (2020) by cowl on Friday February 11, 2022 @11:04AM (#30302994)
This is a symtom of seeing everything with the OOP and state glasses.

let's have do_stuff=square and some_state=2.

What does square(2) imply?

Re:Case against OOP is understated, not overstated (2020) by jshen on Friday February 11, 2022 @12:22PM (#30304082)
Better yet, what does 2.square() imply.
Re:Case against OOP is understated, not overstated (2020) by jshen on Friday February 11, 2022 @10:42AM (#30302688)
Immutability is independent of whether something is a method call vs a function call.