10
Cyanide
3y

Why is OOP hated, here?

How is functional programming much better than OOP? (as stated by so many peole here)

Comments
  • 13
    Its religious
  • 10
    It isn't hated and both have their usage:
    When you need to carry lots of state around, go for OOP.
    Else go for Functional.
    In both cases, whenever you can get away with it, go for immutability/pureness.
  • 4
    @Oktokolo +1 on what you said
    @Cyanide I’d bet it’s due to legacy code with a lot of huge functions being basically switch statements for internal state(s)
  • 10
    Who hates a paradigm? That's dumb. Plus they aren't even mutually exclusive either.
  • 4
    @inawhile dis gomment has da wisecrack QUALITY "seal of approval" (tm).

    In Soviet america horses ride YOU.
  • 4
    Functional and OOP styles/methodologies can be mixed and matched within a codebase without a problem. Use what works well and looks nice for a particular bit of functionality in code.

    I guess we are in the middle of a renaissance in functional programming, partly driven by it being arguably better suited for data processing by cleanly representing it as a series of data transformations encoded as functions (BigData, ML), partly because the statefulness embraced by OOP makes behavior less predictable at a glance

    All this runs against what was commonly taught and evangelized: that OOP is a one-size-fits-all paradigm superior to what came before it.
  • 7
    I like Rust. It's neither OOP nor Functional.

    I also like Haskell, the FP-est language ever.

    The issue with pure FP taken to extremes is that things tend to become perfect in an academic and abstract sense very quickly... which helps with correctness, but not with productivity or comprehension.

    The issue with pure OOP is that many abstract things in life are not really modelled well as objects, and not a single OOP language has a fully consistent type system.

    For me, Rust is pretty close to perfect, as it's like "fuck all this paradigm nonsense, let's go for consistency, safety, optimized performance and a solid type system"
  • 1
    I wouldn’t say it’s better, It’s different and not as many people use functional programming the way that they do object oriented programming.

    But most object oriented programming is done very badly. Often I see procedural code mashed into an OO paradigm and the devs have no idea at all what real OO looks like.

    That hasn’t happened yet with functional, but don’t worry it will when the majority move over to it.
  • 1
    @TrevorTheRat That has happened to FP as well.

    JavaScript is what happens when people mash FP morphisms together with imperative code and a weak type system.
  • 5
    Functional is great. It’s clean and everything is individually reliable. I love the idea.

    Object oriented is great; it’s very easy to understand and implement and extend, and allows you to handle extreme complexity with ease.

    Declarative is great. You write what you want to accomplish and it just happens. Great when you don’t care how something works, only that it does.

    Imperative is great. It’s clear exactly what happens, why, and in what order, and it’s the easiest to follow. (Though often not the easiest to read…)

    Every style and approach has its purpose and its place.
  • 1
    Basically OOP is like Muse - incredibly popular, fills stadiums of fans, known all over the world.

    Functional programming is like Igorrr - wtf is that even, most people never heard of it, but if you listen to that then you get to be proud of your exquisit taste.

    If it was vice versa, then these sentiments went the other way too. If functional programming was the widely used one, then OOP evangelists were writing about how the structure and encapsulation of the OOP model are sublime and magnificent.

    So I wouldn't measure the quality of either model by the amount of posts that are pro or contra. Best is to explore both yourself and develop an opinion.

    One caveat exists though. The industry needs to standardize, i.e. there must be a common denominator on how to solve certain problems. Since OOP is widely used there are not that many niches for functional programming if you prefer that model - but they do exist.

    Frankly many languages utilize elements of both. Look into Scala
  • 1
    My fingerpainting level gripes with OOP languages is not enough support mixins, nor abstract base classes, nor interfaces.

    That is all.
  • 2
    @Maer No, standardizing is not helpful here.

    OO works great for some things, imperative for others, declarative for some. Forcing everyone to use the same methods for everything would be extremely counterproductive. These different approaches exist for a reason.
  • 3
    OOP or any other style is bad if it’s used improperly, or if it’s the wrong approach. It’s like saying a pistol is bad bc it can’t kill a deer efficiently 🦌 lol
  • 4
    @Root @Maer

    I think there's productivity vs correctness, and generic applicability vs complex scalability

    Weakly-typed, dynamic, OOP-ish languages allow for rapid, albeit sloppy development. If my boss says "We have an emergency! We need a page online within 60 minutes where people can upload their covid vaccination certificate so they can join the orgy!" -- I'm going to use PHP (Py/Rb/Js/etc), not Haskell.

    PHP is hard to scale though. Not impossible, but keeping a large codebase scalable and bug-free is difficult. Easy to make small mistakes which lead to data corruption or 500 errors.

    Haskell is correct, to an extreme degree. If it compiles, I'm fairly certain it's bug free even if I wrote zero tests. I've written biochem simulations, xray dicom processing software and credit provider backends in Haskell.

    However, Haskell is not always efficient. If efficient and leak-free use of memory & predictable CPU usage was a requirement, I might use Rust.

    ...etc
  • 3
    @Root I believe we are in agreement. What I was saying is that standardization (not in the sense of applying ISO standards but to require a specific tech stack and approach to solve problem X) can stand in the way of variety.
  • 1
    @Maer Oh. Okay. I must have misread your comment. Apologies :)
  • 2
    @inawhile Yup. As soon as a buzword gets some traction, every idiot wants in on the action, some really bad code is rolled out, and everyone starts to believe the thing is the problem, and exchange it for another thing.

    Just like how the West recycles the word for "migrant" every so often, once the old word has collected too many negative connotations. This won't stop untill we are out of words to corrupt.
Add Comment