• Antithetical@lemmy.deedium.nl
    link
    fedilink
    arrow-up
    13
    ·
    edit-2
    4 hours ago

    As a life-long developer in OOP languages (C++, Java, C#, among others) I still think OOP is quite good when used with discipline. And it pains me that there is so much misunderstood hate towards it nowdays.

    Most often novice programmers try to abuse the inheritence for inpropper avoiding of duplicate code, and write themself into a horrible sphagetti of dependencies. So having a good base or design beforehand helps a lot. But building the code out of logical units with fenced responisbilities is in my opinion a good way to structure code.

    Currently I’m doing a (hobby) project in Rust to get some feeling for it. And I have a hard time to wrap my mind around some design choices in the language that would have been very easily solved with a more OOP like structure. Without sacrificing the safety guarantees. But I think they’ve deliberatly avoided going in that direction. Ofcourse, my understanding of Rust is far from complete so it is probably that I missed some nuance… But still I wonder. It is a good learning experience though, a new way to look at things.

    The article was not very readable on mobile for me but the examples seemed a bit contrived…

    • nous@programming.dev
      link
      fedilink
      English
      arrow-up
      8
      ·
      3 hours ago

      I think a lot of people conflate OOP and inheritance to mean the same thing. And inheritance is what should get the bad rap. It does not solve any problem I have seen any better than other language features (in particular interfaces/traits can solve a lot of the same problems) but inheritance causes far more problems overall.

      But building the code out of logical units with fenced responisbilities is in my opinion a good way to structure code.

      This is encapsulation, which is one of the better ideas from OOP languages. Though also not unique to them.

      And I have a hard time to wrap my mind around some design choices in the language that would have been very easily solved with a more OOP like structure.

      What design choices would those be? And how would they better fit into an OOP like structure? Note that rust is not anti OOP - it uses OOP techniques a lot throughout the code base. It just lack inheritance and replaces that with other IMO better features.