5 ms·
I'd say this more or less the mainstream view these days. Both Go (2012) and Rust (2015) decided to do polymorphism with a trait system rather than inheritance,
by oconnor663 8y ago
I'd say this more or less the mainstream view these days. Both Go (2012) and Rust (2015) decided to do polymorphism with a trait system rather than inheritance, for example.
- krapp 8y agoNeither Go nor Rust are mainstream -- that's still C++, Java and Javascript.
- klodolph 8y agoNew languages can reflect mainstream opinions even if the languages are not mainstream. Mainstream languages tend to represent fossilized opinions from the time when they were designed.
- oconnor663 8y agoGo is #12 on the TIOBE index, and by that measure more mainstream than Perl or Ruby. If by mainstream you mean "the top 3-5 programming languages", then you're not talking about anything invented in the last 20 years, which is kinda the point.
- nouseforaname 8y agoIf we were to use a car analogy: go has been in production for the last few years and there's a ton on the road, but the average car on the road wasn't built in the last few years.
- coldtea 8y agoThe mainstream is not only defined by what's most popular, but also by what sets the trends. The masses always get the message with some delay... Besides, all of the three languages that you've mentioned are turning more functional and less OO with each year... JS still has OO (and recently got "classes" as sugar), but it's not used in the crazy deep-OO-hierarchy style at all. Java, that used to cherish that style also abandons it nowadays (with closures, streams, etc.).
- sdegutis 8y agoI can count on 0 hands how many times I have used inheritance in the past 6-7 years. And if you don't count times that a framework requires me to use it to accomplish something, like React.Component or NSTableView, then that number goes back something like 15 years.
- pdimitar 8y agoIt boggles my mind that inheritance is still taught in schools and universities. It's so easy to debunk the common lovely idea of "Square and Circle are a type of Shape, Rectangle is a type of Square" that it's not even worth talking about it -- you might want the square to be rendered in a GUI framework but have the Circle rendered only in your PDF reports, being one very lame example I can think of in under a minute. Many others exist on the net and they are much better than mine. (Traits of types -- and thus multiple inheritance -- make much more sense if you so want to model the real world.) "OOP is necessary" is a lie that is worth billions of dollars. Inheritance ends up being leaky and non-isolated. Every time.
- sdegutis 8y agoInheritance works great in mathematics because then it's all about using some laws to compute derived properties, but in programming we use objects for behavior with side effects. So it's like apples and oranges.
- dan-robertson 8y agoI’m not really sure where you think mathematics is full of inheritance. Do you have an example? Off the top of my head: Subsets, sub-anything-else, not really inheritance Definitions of the form an X is a Y with the following extra properties, I think don’t really count as inheritance either. Example: A ring is a group with ..., but if you wanna to prove anything interesting about a ring, you can’t kust use the group properties or you would have proven a theorem about a group, and so the only useful thing about the group structure is that you know what it is. Any useful theorems will need other useful definitions (eg homomorphism) and these don’t get inherited and so the isomorphism theorem for groups doesn’t become the isomorphism theorem for rings “for free”. There’s also the fact that a field is a ring plus an extra property but most ring things become basically useless because much ring weirdness becomes trivial in a field and what is not trivial in a field is typically impossible in a ring, so knowing about rings doesn’t tell you much about fields. Example: a topological space is a set plus a subset of its power set such that ... but all the interesting things in topology typically have little to do with those sets and more to do with eg functions (but not just any set function) and the added properties. I suppose the theme is that one adds structure to (ie inherits from?) something because the new structure bans a lot of the weirdness of the bigger thing and allows for more interesting things to be done. The structure of the bigger thing is therefore not so useful because what is known about it is less relevant once more structure is imposed. In applied maths, the Fourier and Laplace transforms are part of a more general family of integral transforms yet this knowledge is basically useless in their application and it would not make much difference if they were not related. Fourier series fall into part of a bigger theory called Sturm-Liouville theory but in many of the places one uses a Fourier series this bigger picture is not relevant whereas the specific details about Fourier series are. This is not to say that Sturm-Liouville theory is not useful.
- still_grokking 8y agoI wouldn't say Go has anything comparable to Rust traits. https://softwareengineering.stackexchange.com/questions/247298/how-are-rust-traits-different-from-go-interfaces https://softwareengineering.stackexchange.com/questions/2472...