Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
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. -
Hazarth95374yInheritance 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
-
@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. -
@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.
-
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. -
iiii90854y@AlmondSauce actually, with concepts in C++20 we would be able to write generic inheritance-less code as well.
Related Rants
Inheritance can be bad, boys. I salute the new languages that avoid it.
rant
inheritance
oop
rust
go