You are viewing a single thread.
View all comments
53 points

The day I learned that Linus shares my disdain for all things OOP was such a good day for me.

permalink
report
reply
23 points

I feel the OOP debate got a bit out of hand. I hate OOP as well, as a paradigm.

But I love objects. An object is just a struct that can perform operations on itself. It’s super useful. So many problems lend themselves to the use of objects.

I’ve been writing a mix of C and C++ for so long I don’t even know where the line is supposed to be. It’s “C with objects”. I probably use only 1% of the functionality of C++, but that 1% is a huge upgrade from bare C IMO.

permalink
report
parent
reply
2 points

I think the problem with OOP is something you can see whenever legislation is linked with prestige (it happens a lot in real life). The number of good possible rules is quite limited, and the number of people who want to make a name for themselves by championing them seems to be infinite. If you can’t find a good rule to claim as your own, you have to pick a bad rule and try to gaslight people into thinking it’s a necessary and beneficial. Enough people do that, and we end up with modern OOP.

permalink
report
parent
reply
13 points

Agreed. Objects are nice and a great way to program. Composition is great. Traits/interfaces are great. Namespaces are great. Objects are a really nice way to reap the benefits of principles like these.

But then there are aspects of OOP that absolutely suck, like inheritance. I hate inheritance. The rules get very confusing very quickly. For example, try understanding overriding of methods. Do I need to call the superclass method or not? If not, does it get called automatically? If so, in what order? How do these rules change for the constructor? Now repeat this exercise for every OOP language you use and try not to mix them up… Java, C++, Python, etc.

Fortunately, it feels like we rely on inheritance less and less these days. As an example, I really like how Java allows you to implement Runnable these days. Before, if you wanted to run a thread, you needed a separate object that inherited Thread. And what if that object needs to inherit from another one too? Things would get out of hand quickly. (This is a very old example, but with lambdas and other new features, things are getting even better now.)

Anyway, long story short, I think OOP is a complicated way to achieve good principles, and there are simpler ways to achieve those principles than a full OOP implementation.

permalink
report
parent
reply
1 point

I’ve seen this thing where people dislike inheritance a lot, and I have to admit that I kind of struggle with seeing the issue when it’s used appropriately. I write a bunch of models that all share a large amount of core functionality, so of course I write an abstract base class in which a couple methods are overridden by derived models. I think it’s beautiful in the way that I can say “This model will do X, Y, Z, as long as there exists an implementation of methods A, B, C, which have these signatures”, then I can inherit that base class and implement A, B, and C for a bunch of different cases. In short, I think it’s a very useful way to express the purpose of the code, without focusing on the implementation of specific details, and a very natural way of expressing that two classes are closely related models, with the same functionality, as expressed by the base class.

I honestly have a hard time seeing how not using inheritance would make such a code base cleaner, but please tell me, I would love to learn.

permalink
report
parent
reply
4 points

Yeah it’s pretty great, especially when so many people are so quick to assume that OOP is essential for managing complexity.

OOP is the poster child for solving the problems that it creates itself.

permalink
report
parent
reply
13 points

He is is OK with OOP. The Linux kernel is full of OPP C, but he doesn’t like C++

permalink
report
parent
reply
5 points

He writes Qt C++ for his diving app though.

permalink
report
parent
reply
4 points

I think Linus did it in C with GTK but who took it moved it C++ and Qt. Lazy searching didn’t dig up the story.

permalink
report
parent
reply
0 points

He’s not though, you should look into it

permalink
report
parent
reply
3 points

Look at the kernel code. It’s full of OOP C. There absolutely are objects in the kernel.

permalink
report
parent
reply
78 points

Me, when Linus’ opinion is different to mine: “Linus has such weirdly strong opinions about this

Me when Linus’ opinion is the same as mine: VINDICATION

permalink
report
parent
reply
5 points

peak hairless ape

permalink
report
parent
reply
6 points

permalink
report
parent
reply

linuxmemes

!linuxmemes@lemmy.world

Create post

Hint: :q!


Sister communities:

Community rules (click to expand)

1. Follow the site-wide rules
2. Be civil
  • Understand the difference between a joke and an insult.
  • Do not harrass or attack members of the community for any reason.
  • Leave remarks of “peasantry” to the PCMR community. If you dislike an OS/service/application, attack the thing you dislike, not the individuals who use it. Some people may not have a choice.
  • Bigotry will not be tolerated.
  • These rules are somewhat loosened when the subject is a public figure. Still, do not attack their person or incite harrassment.
3. Post Linux-related content
  • Including Unix and BSD.
  • Non-Linux content is acceptable as long as it makes a reference to Linux. For example, the poorly made mockery of sudo in Windows.
  • No porn. Even if you watch it on a Linux machine.
4. No recent reposts
  • Everybody uses Arch btw, can’t quit Vim, and wants to interject for a moment. You can stop now.

Please report posts and comments that break these rules!

Community stats

  • 6.5K

    Monthly active users

  • 1.3K

    Posts

  • 71K

    Comments