4 ms·
> existing programming languages have little or no subtyping [...] If you remember the fad for Object Oriented Programming I was under the impression that even
by pansa2 2y ago
> existing programming languages have little or no subtyping [...] If you remember the fad for Object Oriented Programming
I was under the impression that even today, most code is written in an object-oriented style (or at least, written in languages that support OOP). Therefore, most languages support subtyping via inheritance. Is that not true?
- josephg 2y ago> I was under the impression that even today, most code is written in an object-oriented style (or at least, written in languages that support OOP). Whoa there - those are very different claims! Most modern languages are multi-paradigm. You can write Python in an OO way, or a data oriented way, or a functional way, or whatever you like. The same is true of JavaScript/typescript. And modern Java. And lots of languages. Just because the language has the class keyword doesn’t mean everything can be subtyped. If you have an entity-component system, you can’t necessarily inherit from your Entity type. Likewise I can’t inherit from a react component, just because JavaScript has classes. (At least not using modern react)
- kllrnohj 2y ago> Most modern languages are multi-paradigm. [..] And modern Java. Modern Java is still very definitely OOP and not multi-paradigm. Other JVM languages, like Scala or Kotlin, add more multi-paradigm features to that ecosystem, but modern Java doesn't.
- diroussel 2y agoIt tries to be OOP, but you can still implement a program with int, int[] and static methods. And you can’t subtype those. Other JVM languages, like scala, are more OO than Java.
- tkcranny 2y agoJava has made some big strides here to catch up with the functional and data-oriented features other languages are all adding. I was pretty surprised and impressed to see a modern example lately. There’s Record data types, stronger type inference with `var`, pretty great structural pattern matching, switch expressions (that return a value), stream apis for map, filter, and reduce etc. All of these move it further away from strictly OOP. And separate but still cool is a pretty neat virtual thread system too. Java has definitely had a bit of a glow up since I learned it in uni.
- pansa2 2y ago> Whoa there - those are very different claims! I suspect that the stronger claim is true - but even the weaker claim would invalidate the article's statements that "existing programming languages have little or no subtyping" and that OOP was a "fad" and has been left in the past.
- dataangel 2y agoYou're absolutely correct, just look at the top languages and what's idiomatic in them
- kragen 2y agoSome languages have separate inheritance and subtyping relations, or have inheritance and no static typing, but yes, this statement makes it clear that the author is either astoundingly clueless, intentionally dishonest, or joking.
- mrkeen 2y agoSate your curiosity and read the next 21 words following your quote. > , “subtyping” might call to mind classes and inheritance hierarchies. However, subtyping is a far more basic and general notion than that.
- adelmotsjr 2y agoThat does not address the fact that yes, inheritance is one type of subtyping polymorphism, and that many languages have them via OO paradigm. Yes, there are other forms of subtyping, but saying that many languages don't have subtyping just because they don't have these other forms of subtyping is either cluelessness or satire.