pull down to refresh

I don't want to start holy war, but I thought I'd share my rant from the other day.
tldr OOP is a tool and shouldn't be treated like an all-or-nothing programming paradigm.
OOP is best suited to problems where you have lots of varied and complex state and many instances of complex state. The history of OOP certainly suggests that at least - it was initially used for simulations, ie many instances of varied complex state evolving over time. Then it found market-fit in GUI frameworks which face a similar problem. Then programmers, with this hammer, treat everything like a nail. They use OOP to solve problems with primitive and singular state, tightly coupling logic to state merely out of habit.
OOP programmers spend most of their time building more and more complex, and abstract, families of logic-state chimera. As a result OOP code tends to be the hardest to read and reason about because at any point of execution there's a bunch of implicit bespokely organized state. OOP encourages state, state organization, and mutability rather than state minimization and immutability. It rejects electing the simple, predictable, and obvious execution stack to carry a program's state. When the execution stack carries state:
  1. the complexity of a program's ephemeral state is roughly proportional to its execution depth
  2. state is defined by simple, often primitive, explicit statements exactly where the state begins being used
I think what OOP wants to be is declarative (ie understand these classes, objects, and organization and you know what the code does), which is the way most programming languages and frameworks have evolved, but instead often ends up being the opposite - state mutates state that mutates state that mutates state, times a million, and all according to some random OOP engineer/state architect. Very few problems require the ephemeral, complex, custom, kind-numerous, interdependent state that OOP encourages.
It's also a byproduct of standardization. For any given field of business / research there might be different state formats or existing file extensions (just for example) and some abstraction layer / DSL comes up that makes life easier by wrapping different file formats and implementations. People adopt them on the promise that you only need to learn this new interface and can forget the rest, and in a lot of cases it really works. When it works, it's fine and saves a lot of time, but when some dependency fails or there's some kind of breaking change, it's annoying to hunt down and reason about.
reply
I think state belongs in a database. This allows you to base your logic on pure functions. Anything that is mutable can be managed by the db.
reply
That's the tradeoff when not using OOP usually, a global data store, but OOP programs usually end up with one anyway. And, the benefit of most data stores is they feature a declarative access language, so IMO it's not much of a tradeoff.
reply
OOP is a tool and shouldn't be treated like an all-or-nothing programming paradigm
This ^^
reply
Yup. Every programming language and design practice is a tool!
Just remember you’re not a tool, _the compiler is_🤣
reply
this riff from Jose Valim on inheritance in OOP was pretty funny imo https://www.youtube.com/watch?v=agkXUp0hCW8&t=1299s
obvs it's coming from a FP perspective.
reply
True
reply