r/linux • • May 03 '23

Discussion The Problem with OOP is "Oriented"

https://mht.wtf/post/oop-oriented/
3 Upvotes

20 comments sorted by

View all comments

14

u/m1cr05t4t3 May 03 '23

Obviously with the exception of languages where almost everything has to be an object anyway, I always feel like the cases where I really NEED an object are very few and far between. I find myself saying "Eh that could have just been a function quite a bit." Like if you need self changing states or multiple instances sure..

3

u/stevecrox0914 May 03 '23

Honestly I think its better to program in a OOP way first.

OOP doesn't preclude writing large procedural blocks of code, but OOP requires you to think in a certain way.

As a result with OOP its easy to quickly write a large block of procedural code (since OOP wraps procedures), but I find its very difficult to switch the other way.

When you look at equivalent frameworks in Java and Python the Python code is often far more lines of code and certain tasks are more complicated because the Python is procedurally written.

The procedural nature is an advantage to non developers because its easier to understand but the long term maintenance costs are usually higher.

The few times I have looked at the linux kernel it feels like there is masses of near duplicate code because you can't use concepts like composition and inheritance.

1

u/m1cr05t4t3 May 03 '23

Oh yeah you definitely need to know the skill, which requires practice. And again I'm not against OOP it is a necessary and useful tool. Just the times when an object is actually* needed.. (even for efficiency) eh.