Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I think bad OOP is still better than bad functional code. Having seen what happens when a React codebase reaches >100k LOC are we really any better off than a class hierarchy?

The OOP model fits nicely into most people’s heads because of the analogy to the real world and OOP implementations generally seem to give better signals when you are doing something wrong. Rather than functional implementations which mainly rely on human expert code reviewers and linters to give negative signals instead of say exception hierarchies.

A lot of the time you don’t realize your codebase is bad until “it’s just a button how hard can it be” somehow takes 3 months and 4 rollbacks.

At least this is what I have observed working on large codebases.



> The OOP model fits nicely into most people’s heads because of the analogy to the real world

It also has been the default programing language paradigm for a while now, which I think explains why experienced programmers can cling to it despite its drawbacks. Try to teach object oriented programming to a beginner and it becomes clear that it isn't as natural as you are suggesting.

> generally seem to give better signals when you are doing something wrong.

Better than what? Functional programming is a far simpler abstraction: a function. Data in, data out. That's about as simple as it gets. Also, culturally, functional programmers generally understand the downside of distributed state, and actively try to minimize it. That's a good thing.

Bad code is bad code, but OOP gives you unique weapons to hurt yourself with. Inheritance allows one to change an unbounded number of objects without you even knowing. Modeling everything as a collection of objects with state tends to lead to programs that need to synchronize distributed state rather than a central state that is easier to keep consistent.


That's because the programming language used is not FP, even if people pretend to.

Js is still stateful everywhere, even where you don't want it to be


> Having seen what happens when a React codebase reaches >100k LOC are we really any better off than a class hierarchy?

I’m not sure if you correctly understand what functional programming is.

Check out Grokking simplicity, great book.


I assume you're talking React's hooks. That is not functional programming.


> The OOP model fits nicely into most people’s heads because of the analogy to the real world

Nothing in real world resembles OOP.


A poodle is a dog is an animal. That's about it, for everything else it's non-intuitive.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: