• MajorHavoc@programming.dev
        link
        fedilink
        arrow-up
        4
        ·
        5 months ago

        Yep. I’m old, cranky, and prone to broad statements to get reactions.

        That said, for any of you all that love inheritance, I’m judging you so hard. So hard. Very judged. I probably hate your code, and your friends’ code, and your last teacher’s code. Especially your last teacher’s code.

    • parlaptie@feddit.de
      link
      fedilink
      arrow-up
      1
      ·
      5 months ago

      There’s the camp of those who say that inheritance is synonymous with OOP. I’m not in that camp, but I’d like to see you duke it out with them.

      • HereIAm@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        5 months ago

        You will still have private/public sections, interfaces (unless you class them as inheritance), classes and instances, the SOLID principles, composition over inheritance. OOP is a lot more than just large family trees of inheritance, a way of thinking that’s been moved away from for a long time.

  • Artyom@lemm.ee
    link
    fedilink
    arrow-up
    1
    ·
    5 months ago

    Inheritance makes complicated objects that would otherwise be impossible possible, but it only works if you know those objects really well. The problem is people write ridiculously complicated mystery objects in libraries and no one knows what’s going on anymore.

  • kibiz0r@midwest.social
    link
    fedilink
    English
    arrow-up
    1
    ·
    5 months ago

    The venerable master Qc Na was walking with his student, Anton. Hoping to prompt the master into a discussion, Anton said “Master, I have heard that objects are a very good thing - is this true?” Qc Na looked pityingly at his student and replied, “Foolish pupil - objects are merely a poor man’s closures.”

    Chastised, Anton took his leave from his master and returned to his cell, intent on studying closures. He carefully read the entire “Lambda: The Ultimate…” series of papers and its cousins, and implemented a small Scheme interpreter with a closure-based object system. He learned much, and looked forward to informing his master of his progress.

    On his next walk with Qc Na, Anton attempted to impress his master by saying “Master, I have diligently studied the matter, and now understand that objects are truly a poor man’s closures.” Qc Na responded by hitting Anton with his stick, saying “When will you learn? Closures are a poor man’s object.” At that moment, Anton became enlightened.

    • CapeWearingAeroplane@sopuli.xyz
      link
      fedilink
      arrow-up
      0
      ·
      5 months ago

      Can someone please enlighten me on what makes inheritance, polymorphism, an operator overloading so bad? I use the all regularly, and have yet to experience the foot cannons I have heard so much about.

      • masterspace@lemmy.ca
        link
        fedilink
        English
        arrow-up
        0
        ·
        edit-2
        5 months ago

        Because an object is good at representing a noun, not a verb, and when expressing logical flows and concepts, despite what Java will tell you, not everything is in fact, a noun.

        I.e. in OOP languages that do not support functional programming as first class (like Java), you end up with a ton of overhead and unnecessary complications and objects named like generatorFactoryServiceCreatorFactory because the language forces you to creat a noun (object) to take an action rather than just create a verb (function) and pass that around.

        • CapeWearingAeroplane@sopuli.xyz
          link
          fedilink
          arrow-up
          0
          ·
          5 months ago

          This makes sense to me, thanks! I primarily use Python, C++ and some Fortran, so my typical programs / libraries aren’t really “pure” OOP in that sense.

          What I write is mostly various mathematical models, so as a rule of thumb, I’ll write a class to represent some model, which holds the model parameters and methods to operate on them. If I write generic functions (root solver, integration algorithm, etc.) those won’t be classes, because why would they be?

          It sounds to me like the issue here arises more from an “everything is a nail” type of problem than anything else.

    • Blemgo@lemmy.world
      link
      fedilink
      arrow-up
      3
      ·
      5 months ago

      I think the main problem is that people try to shoehorn OOP mechanics into everything, leading to code that is hard to understand. Not to mention that this is basically encouraged by companies as well, to look “futuristic”. A great example of this approach going horribly wrong is FizzBuzz Enterprise Edition.

      OOP can be great to abstract complex concepts into a more human readable format, especially when it comes to states. But overall it should be used rarely, as it creates a giant code overhead, and only as far as actually needed.

      • RandomException@sopuli.xyz
        link
        fedilink
        arrow-up
        1
        ·
        5 months ago

        Oh no, the FizzBuzz EE has evolved since I’ve last viewed it! 😱 Is it bad if it actually reminds me of my current work project’s backend (that I haven’t written) a bit?

  • Caveman@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    5 months ago

    Using classes is nice tbh. Using inheritance usually isn’t. Inheriting from inherited class should be forbidden.

    • azertyfun@sh.itjust.works
      link
      fedilink
      arrow-up
      0
      arrow-down
      1
      ·
      5 months ago

      Anyone who praises FP is either a student, works primarily in academia, or otherwise never had to look at a deep stack trace in their life.

      Every time a production system spits out a backtrace that’s just 15 event loop calls into a random callback, I lose 6 months life expectancy. Then I go look at the source, and the “go to definition” of my LSP never works because WHY WOULD IT, IT’S ALL FUNCTIONAL hapi.register CALLS

      I hate it I hate it I hate it I hate it. I support UBI because the people pushing functional programming in real production systems should be reassigned to gardening duties.

      • arxdat@lemmy.ml
        link
        fedilink
        arrow-up
        2
        ·
        5 months ago

        I’m not advocating one way or the other, but I would gladly take on the gardening duties :D

      • Miaou@jlai.lu
        link
        fedilink
        arrow-up
        1
        ·
        5 months ago

        I have the same problem with oop. 10 levels of encapsulated calls just to see you were in an overridden methods without enough data to find out which implementation it was. Ugh

  • HStone32@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    5 months ago

    I used to think I was just a fanboy. But as time went on and I gained more and more experiences, I’ve only become all the more sure that ANSI C is the only language I ever want to write anything in.

    • Jears@social.jears.at
      link
      fedilink
      arrow-up
      1
      ·
      5 months ago

      I was the same, but I recently gave zig a try, it’s lovely to write.

      Managed to segfault the compiler though, so maybe not quite ready yet.

  • anyhow2503@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    5 months ago

    I haven’t used TypeScript in a classically OOP way and it never felt like I was being urged to do so either.

    • Armand1@lemmy.world
      link
      fedilink
      arrow-up
      0
      ·
      edit-2
      5 months ago

      I’ve worked on projects with 10 000+ lines of typescript and maybe 3 classes total.

        • Armand1@lemmy.world
          link
          fedilink
          arrow-up
          1
          ·
          5 months ago

          Of course, but OOP is typically about putting methods on classes, inheritance of behaviour etc.

          JS Objects aren’t typically used that way, they tend to be used as pure data containers. At least, that’s how we mostly use them.

          Occasionally, we’ll use objects to simplify passing multiple arguments including arrow functions, but I’d say that doesn’t really count unless the arrow function mutates the object it’s a part of.

          • Ethan@programming.dev
            link
            fedilink
            English
            arrow-up
            0
            ·
            5 months ago

            Of course, but OOP is typically about putting methods on classes, inheritance of behaviour etc.

            You’re referring to one subtype of OOP. That may be what most people mean when they say OOP, but that doesn’t make it correct. Object-oriented programming is programming with objects, which does not require inheritance or classes.

            • Miaou@jlai.lu
              link
              fedilink
              arrow-up
              1
              ·
              5 months ago

              With such a broad definition you could call even Haskell an oop language

              • Ethan@programming.dev
                link
                fedilink
                English
                arrow-up
                0
                arrow-down
                1
                ·
                5 months ago

                So you’re arguing that “Object oriented” shouldn’t apply to languages that are oriented around objects?