|
|
|
|
|
by ribit
1748 days ago
|
|
Well, "classes" in the mainstream programming are data types that are bound by an inheritance hierarchy. Which is exactly the problem of the "popular OOP": polymorphism (behavior) is constrained by inheritance. You cannot add a behavior to an object if that object is not part of the correct hierarchy. Once you separate type hierarchy and behavior, you get a much more flexible system. That's what newer languages (Rust, Swift and co.) do. I think the reason why "classes" are so popular has to do with compiler technology — type hierarchies can implement polymorphism very efficiently via vtables, and folks jumped on the opportunity of having high-level abstractions with high performance (instead of doing expensive lookups associated with earlier per-instance polymorphism). But as the compiler tech and understanding of programming language theory have progressed, these limitations are not necessary for good performance anymore, in fact, they become limiting. |
|