Object-Oriented Programming is Not What You Think It Is, or at Least It Wasn’t Meant to Be

Moisés Cristiano - Aug 21 - - Dev Community

"When I coined the term 'object-oriented,' let me tell you, I wasn't thinking of C++. The big idea is 'messaging'... The key to creating good and extensible systems lies much more in designing how your modules communicate with each other than in how their internal properties and behaviors should be."
"I regret having coined the term 'object' a long time ago regarding this subject because it makes people focus on the smaller idea. The big idea is 'messaging.'"
— Alan Kay, creator of the Smalltalk language.

When we learn object-oriented programming, the first thing we're shown is the idea that a car has attributes like doors and wheels, that a television has the behavior of turning on and off, that a house has windows that can open and close. But real systems are far from looking like that.
You'll see an object called HTTPRequest, but you won't see one called television. You'll encounter logMessage, but not house1Joao. Or also, resourceManagement, fileSystem, etc. And now, what behaviors should these "objects" have?

The idea of objects as representations of real-world objects appears even before Alan Kay with the Simula language. The creators of the language, Ole-Johan Dahl and Kristen Nygaard, were designing a language to be used for simulations of reality, such as queues, network traffic, manufacturing processes, etc. Procedural programming was not suitable for solving this type of problem.

This is where the need for a form of programming that allows you to focus on what really matters and leave the implementation under the hood begins. Imagine having to build a robust and large system thinking more about the code's details than the problem itself. Not to mention that the number of functions a code could have was large enough to become a confusing and obscure tangle.

They took the first step in abstracting unnecessary concepts in programming.

"But that's exactly modern OOP!" You might be exclaiming. Well, yes and no. The implementation of the Simula language for this paradigm was different. There was no focus on reusable and flexible systems but on modeling events and processes.
Inheritance was simple. The focus was on refining and specializing procedures rather than flexibility and hierarchies.
Encapsulation was basic. There was no concept of access modifiers like private, public, and protected.
Basically, the idea was to organize code chaos into packages with clearer definitions.

Some time later, at Xerox, Alan Kay came up with his idea of messages. At the same Xerox that created computer graphics and Smalltalk.
His idea was basically to think of objects as living beings, but not as animals or humans, but as cells. (Alan Kay was a biologist by training.)
Living tissues function perfectly thanks to the communication between cells. They have their functions very well defined and know how to respond to the 'messages' they receive from other cells.
The idea was to create objects whose function was to know how to respond to messages in their own way. It is not necessary, and it shouldn't be, to know how the object's response is implemented. The only thing you need to know is what kind of message the object understands. (In fact, the set of messages you can 'send' to the object is called an Interface.)
For example, what do you expect the sum object to return when you send the message "2 + 2"?
Ah, yes. In Smalltalk, everything is an object, including messages.
Yes, I know, it's crazy. Objects communicating through objects that contain other objects. But that's the idea.
"Okay, and how does this help create reusable and extensible systems?"
Software systems are more like wiring than a file. And that's the distinction Alan Kay makes.
To him, you should worry about whether the wires are connected to the correct poles and not about how a file is organized.

Conclusion

Object-Oriented Programming, as conceived by Alan Kay, wasn't just about organizing code into structures that mimic the real world, but about creating systems that communicate efficiently through messages. Although modern OOP has evolved from the initial ideas of Simula and gained popularity with languages like C++ and Java, the true focus of this approach, which is communication between objects, has often been diluted.

Understanding Kay's original vision can lead us to reconsider how we design and build software today. Instead of focusing only on the internal structure of objects and class hierarchies, we should also value the simplicity and flexibility that well-designed communication between modules can bring.

Returning to the roots of OOP can help us develop more resilient, modular, and easy-to-expand systems. After all, as Kay reminds us, the "big idea" wasn't about objects themselves, but about the way they communicate.


Sources:

  1. Alan Kay, "The Early History of Smalltalk," in History of Programming Languages, 2nd ed., edited by Thomas J. Bergin and Richard G. Gibson, Addison-Wesley, 1996, pp. 511-578.
  2. Kristen Nygaard and Ole-Johan Dahl, "The Development of the SIMULA Languages," in History of Programming Languages, 1st ed., edited by Richard L. Wexelblat, Academic Press, 1981, pp. 439-493.
  3. Bjarne Stroustrup, The C++ Programming Language, Addison-Wesley, 2013, Preface and Chapter 1.
  4. Kay, Alan. “The Meaning of ‘Object-Oriented Programming’.” Email to Stefan Ram, 2003.

P.S.: This article was written by Moisés Cristiano and edited by ChatGPT.

. .
Terabox Video Player