3 ms·
OOP was a huge trend in the 90s and I think a lot of devs have learned from experience the ways in which it kinda sucks.. - It doesn’t do great as the code get
by paulhodge 7y ago
OOP was a huge trend in the 90s and I think a lot of devs have learned from experience the ways in which it kinda sucks..
- It doesn’t do great as the code gets older or more complex. Google “fragile base class problem”.
- Inheritance doesn’t do a good job of modeling most real-world problems. Most situations don’t map into a simple “class Dog extends Animal” kind of hierarchy. Steve Yegge’s “the kingdom of nouns” is a great rant on this topic.
- OOP actually requires expert-level knowledge to do right. It seems like it’s beginner-friendly but that’s kind of deceptive. If you’re using inheritance then you should understand Liskov substitution, otherwise it’s not going to work well. And if there’s generics involved then you might need to understand covariance vs contravariance, which is also a beginner-hostile expectation.
Imo, out of the newer languages, I really like Golang’s take. Interface-heavy, no inheritance, and some nice sugar around composition. Dunno if I agree with their lack of generics but I understand the choice, generics create a lot of complexity.
- H8crilA 7y agoOOP is great as long as your inheritance stack is at most 2 classes deep: abstract base classes for different backend implementations, or for holding heterogeneous objects like a syntax tree or, idk, inodes in the kernel, or even just one actual implementation and additional implementations for tests. At which point you may as well call the base class an interface. Can't think of any sensible 3+ classes deep hierarchy that I've seen in a sensible project. I've seen some that are not sensible.
- UK-AL 7y agoMost modern code bases I've seen only use interfaces now. Only in the odd exception do they use inheritance.
- throw0101a 7y ago> OOP was a huge trend in the 90s and I think a lot of devs have learned from experience the ways in which it kinda sucks.. Was that the paradigm or the language implementation of the paradigm? The big two languages in the '90s were Java and C++ (later C#?). If everyone was writings in Lisp/Smalltalk (or even Tcl), would things have turned out differently?
- repolfx 7y agoFragile base classes only affect C++. That's not inherent to OOP. Java solved it completely. Inheritance gets ragged on a lot these days, but frankly I see it all the time in most mature, production codebases and it's usually used properly and in a tasteful manner. IMO the idea that inheritance is evil is just people who want to make a new programming language looking for a philosophical edge - just like how a bunch of language designers decided exceptions suck because "you can't see the control flow" (eg. in Go) and now years later have basically admitted their error handling sucks, so they need to add something very exception-like back in. Actually exceptions never sucked but Go's designers needed some sort of fresh idea to justify their project.