4

Inheritance can be bad, boys. I salute the new languages that avoid it.

Comments
  • 0
    composition goooo
  • 2
    "can" does not mean "is". Your statement is just logically incorrect
  • 0
    The only bad thing about inheritance is casting.
  • 1
    Fun fact: Inheritance was originally invented for Simula to make garbage collection simpler and faster.

    Nowadays it's just a "we do it because it's always been done like that" thing in OOP that doesn't really have much value over composition.
  • 0
    @iiii a little bit to the word, but okay.
  • 5
    Inheritance is bad when you use it wrong. Composition can also be bad if you just compose your classes willy nilly.... That's all there is to it. Languages that avoid it out of spite rather out of utility are wrong and should feel bad
  • 3
    @Hazarth Once you used Rust for a while you see it's not missing out of spite, but simply because it's pointless. Between the enumerators which are powerful enough to replace classes and interfaces on their own, as well as Traits(aka interfaces) and a few concepts borrowed from functional languages it feels complete enough.

    Even more than that, it showed me how much simpler it can be when I don't need to think about what might inherit from which other class if I can just put one inside the other as needed, and at the same time it feels like it maps more directly to what happens in the background.
  • 1
    @deadlyRants another rust cult evangelist?
  • 4
    @iiii Your definition of a cult is a little fucked, but whatever you say. Rust is popular for a reason, so you're gonna have to live with a little mention or two on a post tagged with "rust". I survived years of hype for Yet Another Shit JS Framework, so it's not gonna kill ya.
  • 4
    We're in a phase of bizarre absolutism in the dev world at the moment.

    Inheritance can be useful depending on your paradigm. It's not that you *can't* do the equivalent with composition, it's that logically it just makes more sense in some situations, and in some languages more than others. It makes a lot of sense to have it available in C#. It doesn't make as much sense in Rust.

    It's the same situation with a whole bunch of concepts - mutation for instance. It makes perfect sense in Rust. It makes little sense in a strictly functional language like Haskell. That doesn't mean that mutation is always bad, or should never be used - it means it's more suited to some environments than others.
  • 0
    @AlmondSauce actually, with concepts in C++20 we would be able to write generic inheritance-less code as well.
Add Comment