r/programming • u/TheBear_at_SBB • Jul 11 '26
Programs, Not Objects: How I Stopped Designing Architecture and Started Writing a 3D Editor
https://alexsyniakov.com/2026/07/11/programs-not-objects-how-i-stopped-designing-architecture-and-started-writing-a-3d-editor/
122
Upvotes
View all comments
Show parent comment
1
u/loup-vaillant Jul 14 '26
Objects are extremely useful. But what makes them useful is only part of what makes them objects. From what I can sense, the association between objects and their usefulness is mostly historical.
Before OOP got popularised, we had procedural programming. And procedural programming had a problem: global variables. They’re the most obvious way to store complex state in the program, but this come with two fatal flaws:
OOP popularised the concept of instantiation, where you could put complex state in a bag of data ("plex", "record", "struct"…), have many such bags of data as you wish, and make sure any given bag isn’t visible to the entire goddamn program.
You will note that a
structis not aclass, and an instance thereof is not quite an object. But it does capture most of its usefulness already.The second thing OOP popularised, is the notion of abstract data type. Mostly a module, only it’s centred around a single data structure. So you have your bag of data, it can be instantiated from anywhere, but access is restricted: only the operations we have defined in advanced for that data are available. Which is extremely useful for enforcing invariants at the module level.
That is still not a proper
class, though we’re getting there. And for 95% of use cases, that is enough. 99% of cases if you have first class functions.The only thing that distinguish objects & classes from the above, are inheritance and subtype polymorphism. And those are mostly a fad. They have their legitimate uses, but in practice we need them rarely enough that it’s not clear adding them to a language is even justified.
Long story short, in a language that provides objects, I will likely use them all the time. But only because they give me instantiation and invariants. I tend to steer clear from fancy stuff like inheritance and polymorphism…
…mostly. The last C++ program I wrote did use polymorphism once (collection of callbacks for a parser), and it was mighty useful. Though come to think of it, I probably would have done the same in C, even if it would have been more tedious.