I believe that classes, inheritance and OOP as the leading paradigm for two decades were the worst thing to happen to programming after NULL.
You don’t need classes at all, classes are simply a mix of several concepts that are best kept separate: Currying, namespacing, data structs and closures with a bit of syntactic sugar on top. Worst cake ever.
I code in C, Rust, Typescript and Python, and didn’t code any class in the past 5 years, because classes are never the best option. The mix of data and behavior in particular is horrendous, and made much worse by inheritance (now you don’t know which behavior is used without exploring layers of abstractions).
Inheritance was a solution to a problem caused by classes and would never have existed, had other paradigms been dominant. It caused headaches and bugs for generations of programmers (Think of the ORM problems, etc.).
Just code simple, directly serializable data structures, and functions and you’ll be much happier.
I think we have two failed concepts in classes: inheritance and encapsulation done wrong.
I don't need to explain why making excessive use of inheritance is wrong. Encapsulation is done wrong because you end up with lots of hidden state and a very complicated dependency graph.
Indeed, one of the pillars of OOP is encapsulation. (= encapsulation of state = hiding state = every object can maybe be stateful, but you can't know from the outside).
Meanwhile, one of the pillars of modern programming techniques (FP, React, and others) is to make state very explicit and separated from the rest (Think State Monad, react's useState, etc), because statefulness is now correctly identified as being a major source of problems.
So OOP took us completely in the wrong direction regarding state management, for 2 decades... Understanding in 2014 that was liberating for me.
Comments
I believe that classes, inheritance and OOP as the leading paradigm for two decades were the worst thing to happen to programming after NULL.
You don’t need classes at all, classes are simply a mix of several concepts that are best kept separate: Currying, namespacing, data structs and closures with a bit of syntactic sugar on top. Worst cake ever.
I code in C, Rust, Typescript and Python, and didn’t code any class in the past 5 years, because classes are never the best option. The mix of data and behavior in particular is horrendous, and made much worse by inheritance (now you don’t know which behavior is used without exploring layers of abstractions).
Inheritance was a solution to a problem caused by classes and would never have existed, had other paradigms been dominant. It caused headaches and bugs for generations of programmers (Think of the ORM problems, etc.).
Just code simple, directly serializable data structures, and functions and you’ll be much happier.
I think we have two failed concepts in classes: inheritance and encapsulation done wrong.
I don't need to explain why making excessive use of inheritance is wrong. Encapsulation is done wrong because you end up with lots of hidden state and a very complicated dependency graph.
Indeed, one of the pillars of OOP is encapsulation. (= encapsulation of state = hiding state = every object can maybe be stateful, but you can't know from the outside).
Meanwhile, one of the pillars of modern programming techniques (FP, React, and others) is to make state very explicit and separated from the rest (Think State Monad, react's useState, etc), because statefulness is now correctly identified as being a major source of problems.
So OOP took us completely in the wrong direction regarding state management, for 2 decades... Understanding in 2014 that was liberating for me.