How To Jeremy

Some thoughts on learning how to Jeremy

Intro

I don't think that object-oriented programming is a good thing. There I said.

I know for some this seems like crazy talk but I never have seen the appeal and I think that OOP has served as a deterrent to progress in software development.

I still see people talking about how people need to understand good OOP practices.

Do they? Is there such a thing? Am I taking crazy pills?

Has it brought the benefits that it claims? I don't think so. I think it has only resulted in buggy bloated incomprehensible software.

I also think the industry is slowly moving away from it. I see the trends in new programming languages backing away from OOP first and allowing multiple paradigms like imperative and functional styles.

In the data world, immutable data structures which is a very functional approach is the norm.

So let's look at somewhere places where I think OOP breaks down.

Resuability

So the main selling point for OOP has been reusability. This was supposed to be the holy-grail of OOP.

Joe Armstrong, the creator of Erlang, said this on software reusability:

"I think the lack of reusability comes in object-oriented languages, not functional languages. Because the problem with object-oriented languages is they’ve got all this implicit environment that they carry around with them. You wanted a banana but what you got was a gorilla holding the banana and the entire jungle. If you have referentially transparent code, if you have pure functions — all the data comes in its input arguments and everything goes out and leaves no state behind — it’s incredibly reusable."

The hope for OOP is that you can set up all your hierarchies and then just tweak. If you have a mammal class then you just derive cat and dog and just modify here and there.

I have never seen this work. The goal with OOP was that you could paint in broad strokes (to use my own metaphor) and that would get you most of the way there.

In reality, though programming is more about the fine lines.

It is so hard or impossible to get these high-level abstractions right. What is a file? Blocks on disk, a stream, an entry in the file system? I have seen classes for all those different use cases as they struggle to try to find the perfect abstraction.

And this is the only way that OOP can provide value is if you can capture large abstractions but as you keep expanding these abstractions they quickly become meaningless.

Abstractions are valuable but there are other ways to build them without using this Object Inheritance model.

I think the failure of OOP in terms of reusability is that the object model is not a good abstraction for most software. It is to difficult to create meaningful abstractions using it.

Inhertiance

OOP's main tool to try and reach its goals in inheritance. This is not a feature but a bug. Just like it is hard to get abstraction right, inheritance is a close second.

I think a big thing that we should strive for in tech is simpler solutions. One to one. Design for the constraints and the human brain is the constraint. Inheritance can be a useful tool but one that should be used sparingly.

Especially multiple inheritance. You can see this fatigue in many newer languages, they have abandoned multiple inheritance altogether.

I once saw this graph of how C++ resolves which method to call. It was a picture of madness.

I think we should be able to reason about code quickly, not have to go look up an inheritance chart.

Encapsulation

Again an idea that seems great at first glance, shove all the annoying messy bits behind the wall. Separation of concerns right?

There is some truth to that but there is a huge downside to that.

State management.

I think figuring out how you manage the state of a program to be one of the most important design decisions in a program nay all of programming.

So instead of being mindful of it, OOP is like fuck it put it everywhere.

This is why we have to restart and reboot everything because something got updated and another piece didn't get the memo.

This is why we have bugs that are so hard to reproduce. It is because you have thousands of objects that all have a different picture of the world and then only crash when just one of them drifted too far. Good luck finding which one.

Polymorphism

I have nothing really to say about Polymorphism.

It's great but you don't need OOP in order to have that. Clojure is a great example of having reusable functions that work across various types.

So just why?

To turn the tables as if I had never seen OOP what does it really bring to the table? If you had never heard of it, how would you sell it?

Please tell me what this brings over imperative/functional programming?

Why are we writing all this boilerplate code?

All these multiply inherited class structures that nobody understands?

What should be valued

Here is what I think should be valued in programming.

State management

Being extremely mindful of the state and how that state is managed during the lifecycle of the program.

Deterministic code

Along the same lines, the less state you have the less complexity or entropy. A function that takes in its inputs and returns an output, runs the same no matter if it is the first or the millionth. That can not be said in OOP.

Referential transparency

You should be able to look at a piece of code even for the first time and be able to grasp what it is doing. You can not do that in OOP. You are constantly digging deeper and deeper.

We need to find ways to reduce complexity. We need to abstract only when we truly understand the problem space.

We need to drop this boat anchor called OOP.