Inheritance makes some sense, but composition is much, much easier to understand and work with. Inheritance has well documented problems that composition does not. It’s not so much about being object oriented or not, at least not directly. I could elaborate, but others have said it better anyways. https://en.m.wikipedia.org/wiki/Composition_over_inheritance
This, 100 times. Program for enough years and you'll find composition such a breath of fresh air. But like any pattern/design, the proof is in the pudding; as in, crap code can be written in any shape or format.
Ask HN: Why do new(ish) programming languages eschew OOP features?
31–40 of 234 posts
Re: Ask HN: Why do new(ish) programming languages eschew OOP features?
#32I find complex business logic tends to be best modelled using algebraic data types and functional programming.
Re: Ask HN: Why do new(ish) programming languages eschew OOP features?
#33Inheritance makes some sense, but composition is much, much easier to understand and work with. Inheritance has well documented problems that composition does not. It’s not so much about being object oriented or not, at least not directly. I could elaborate, but others have said it better anyways. https://en.m.wikipedia.org/wiki/Composition_over_inheritance
The article you linked mentions IMHO the biggest disadvantage:
One common drawback of using composition instead of inheritance is that methods being provided by individual components may have to be implemented in the derived type, even if they are only forwarding methods
Code whose only purpose is to "appease the design" and otherwise does absolutely nothing of value is a strong-enough negative reason. It's pure bloat, overhead that gets in the way of both programmers trying to understand/debug and machines trying to execute.
Too much inheritance can lead to a "where is the method" problem, but I think that's still better than the alternative of dozens upon dozens of lines of otherwise useless code, because the former at least does not increase the amount of code that needs to be written/debugged/maintained.
Re: Ask HN: Why do new(ish) programming languages eschew OOP features?
#34Earlier quoted context omitted.
This, 100 times. Program for enough years and you'll find composition such a breath of fresh air. But like any pattern/design, the proof is in the pudding; as in, crap code can be written in any shape or format.
I'm curious why you find it a breath of fresh air? The Wikipedia link in the post you're responding to specifically states that composition over inheritance is an OOP principle. If one needs to abandon OOP to make use of composition, was OOP actually what was being done or was it instead an exercise in creating an class-based taxonomy? (a lot of people seem to fall into this trap)
I've only fell into composition when I got into video game development. We saw it a bit more with Silverlight but now it's such a clear movement (composition over inheritance) that it's in my resume's motto.
Re: Ask HN: Why do new(ish) programming languages eschew OOP features?
#35Unpopular answer: pure fashion. There's nothing wrong with object methods (that's 100% pure syntax vs. a function call) and an implicit "this" scope for symbols (which is just a limited form of dynamic scope[1]). They don't make code hard to understand. OO can be abused to produce bad designs, of course, but that's not an indictment of its syntax. Non-syntactic aspects are maybe a more involved discussion. For an exa…
Re: Ask HN: Why do new(ish) programming languages eschew OOP features?
#36But I will assume you're a better observer than me, and make the following claims:
I think there's two reasons: Object-oriented style inheritance is unsound (inheritance is not subtyping), so academics don't like it. Moreover, classical OO is not composable or extensible - unless you write your own primitives in every application and end up with Java-like verbosity. Therefore, research in new features tend not to be object oriented. Therefore, new languages tend to adopt non-OOP styles.
The other reason is probably that there's enough OOP languages. The effort it takes to create a new OOP language exceeds the effort it takes to shoehorn your OOP algorithm into an existing OOP language. Therefore, there's less motivation from the engineering side.
On the other hand, there's still lots of scope for better functional style languages; that marketplace isn't exhausted yet. Rust, for instance, merges a lot of academic techniques trialled on functional languages with a systems programming architecture.
Re: Ask HN: Why do new(ish) programming languages eschew OOP features?
#37If you'd like to hear the case against OOP in modern programming, the Rich Hickey talks are a pretty good place to start: * The value of values * Simple made easy * Are we there yet? I'm on mobile, but you'll find these easily on the google.
In short OO gets time fundamentally wrong, is unable to represent a discrete succession of values, and entangles state with operation.
OO has been ~35 year wrong turn for the software development industry.
Re: Ask HN: Why do new(ish) programming languages eschew OOP features?
#38Inheritance makes some sense, but composition is much, much easier to understand and work with. Inheritance has well documented problems that composition does not. It’s not so much about being object oriented or not, at least not directly. I could elaborate, but others have said it better anyways. https://en.m.wikipedia.org/wiki/Composition_over_inheritance
but composition is much, much easier to understand and work with. The article you linked mentions IMHO the biggest disadvantage: One common drawback of using composition instead of inheritance is that methods being provided by individual components may have to be implemented in the derived type, even if they are only forwarding methods Code whose only purpose is to "appease the design" and otherwise does absolutely n…
Re: Ask HN: Why do new(ish) programming languages eschew OOP features?
#39If you'd like to hear the case against OOP in modern programming, the Rich Hickey talks are a pretty good place to start: * The value of values * Simple made easy * Are we there yet? I'm on mobile, but you'll find these easily on the google.
https://www.infoq.com/presentations/Simple-Made-Easy/
https://www.infoq.com/presentations/Are-We-There-Yet-Rich-Hi...
If you're going to watch any of these, at least watch "The Value of Values".
Re: Ask HN: Why do new(ish) programming languages eschew OOP features?
#40I think we need languages that bring new paradigms. All that you quoted fail in this respect.