4 ms·
OOP has a "there" there, it's just that the core formalism is user interfaces. If you look up "object oriented programming" on Wikipedia, the first image you ge
by kmeisthax 2y ago
OOP has a "there" there, it's just that the core formalism is user interfaces. If you look up "object oriented programming" on Wikipedia, the first image you get is a UML diagram of a user interface component.
OOP was invented to facilitate old-fashioned "expert systems" type AI research. While that's a nebulous concept[0], it turned out to be really useful to represent (retained-mode) UI in this way. Any mildly complicated UI needs to be a tree structure where the contents of the tree are all different things. You might want to put a button inside of a cell in a scroll list on the right pane of a window, and to do that, all of those things need to...
1. Support arbitrary child objects of different types and data sizes
2. Communicate with a standard set of events and system behaviors
3. But also support modifying those behaviors or introducing new events to fit the present application
Outside of immediate-mode GUIs for games, GUI-approximating text mode applications, and classic Mac OS[1], every UI toolkit worth its salt is OOP. Yes, even USER.dll. Microsoft[2] wrote an object system on top of a non-object-oriented programming language because it was just that useful.
If you aren't doing UI work, OOP loses it's effectiveness. But doing UI work in a non-OOP language is painful, in direct correlation to how non-OOP the language is. e.g. If you're working in Rust, you can probably get by with a bunch of traits and `dyn UiWidget` them; and there might also be something similar for Go; but in C you'd have to manually construct vtables for every object type you plan to include and pass pointers to everything around everywhere.
[0] Yes, the term "AI" has been meaningless for over half a century. Yes, there's probably a link between that meaninglessness and the nebulousness of UI and OOP.
[1] Steve Jobs had been so distracted by the fancy pointer-driven UI at Xerox that he forgot about the OOP language powering it, Smalltalk. He'd fix that immediately at NeXT.
[2] Also, GIMP, whose UI toolkit wound up becoming GTK, and whose object system became GObject.
- orwin 2y agoHaving done UI (and a raytracer) in non-OOP language during my curriculum, I can only strongly agree with parent. OOP is essential to do specific kind of work, including but not limited to UI. I really hate it to be clear, I dislike the paradigm and find it sometimes difficult to understand. I hate the footguns, I hate inheritance chains. I tolerate mixins and interfaces. But I have to admit: in some cases, OOP is what I need , so I use it.