DEV Community

Cover image for Aristotle Laid the Foundation for Object-Oriented Programming
Antonello Zanini for Writech

Posted on • Originally published at writech.run

Aristotle Laid the Foundation for Object-Oriented Programming

Although several years have passed since my first approach to object-oriented programming, I can still sense the confusion it caused me. I was 12 years old. Perhaps, I was not even ready to understand object-oriented programming, or any other programming paradigm, to be honest.

What I clearly remember is experiencing a similar state of confusion when I started studying philosophy in high school. As you are about to learn, this might not a coincidence.

Fast forward 10 years, I am a freelance software engineer who uses object-oriented programming on a daily basis to design and build software. In all that time, I had never really stopped to think about the origins of object-oriented programming. Until I read a philosophy book about Aristotle!

Deeply surprised, I found strong correlations between what the Greek philosopher founder of the Peripatetic school wrote and the concepts behind object-oriented programming.

Let's now try to understand why Aristotle may have laid the foundation for object-oriented programming, and how this might be explained.

Aristotle in a Nutshell

Aristotle was born in 384 B.C. in Stagira and is the last of the "Big Three" of Ancient Greek philosophy. There are thousands of books about Aristotle, and going into the details about Aristotle's life and all his theories would take too long. Thus, Let's focus only on two key elements in Aristotle's metaphysics, potency and act.

Potency

Potency represents what at this moment is not but can become. In other terms, you can think of potency as the possibility of something becoming something else, evolving, or undergoing a change of any kind.

According to Aristotle, potency is connected to the nature of every being. Specifically, potency determines specific limits and characteristics, which specify the nature of a being.

For example, a child does not have the potency to fly or run more than 100 km/h, but they have the potency to become an adult.

Act

Act represents what at a given moment already is. In other words, you can think of act as something that already has been realized or a being that already exists.

For example, a child in act is just a child and cannot become an adult, because they cannot change. At the same time, a child is an adult in potency.

From Potency to Act

Let's better understand the relationship between potency and act with an example.

Photo by Sourabh Panari on Unsplash

A seed in act has the potency to become a tree. As the seed grows, it gradually moves from potency to act. When the seed turns into a tree, it becomes a tree in act. At this point, the seed is no longer in potency.

Then, the tree in act can become a table or any other piece of furniture in potency, and so on.

Object-Oriented Programming in a Nutshell

Object-oriented programming (OOP) was born around 1960 and is now one of the most widely adopted programming paradigms. Alan Kay coined the term in 1983 and is considered the father of OOP. There would be much to say about OOP, but let's focus mainly on two key concepts, class and object.

Class

Classes are the building blocks of the OOP. A class defines what the objects of that class will be. You can think of a class as a template, blueprint, or complete description of objects of that class.

In detail, a class is a user-defined data type that includes some data fields and member functions. These are called "attributes" and "methods," respectively.

A class maps an abstract concept. For example, a Tree class could have a name, an age, a height, and the ability to grow through a grow() member function.

Object

Objects are instances of a class, which determines their type. In OOP, a type defines the characteristics and features shared by a set of objects. So, the structure and behavior of objects of the same type are defined in their class.

In detail, an object is a programming entity composed of methods and attributes. The current values of each attribute represent the state of the object, while its methods identify the possible behavior of the object.

An object maps a concrete representation of an abstract concept. For example, a 7-month-old, 18-centimeter-tall cactus could be an instance of the Tree class.

From Class to Object

To go from class to object, you need to "instantiate a class." This is because in OOP terminology, "instantiating a class" means "creating an object." Therefore, when you create an object, you are initializing an "instance" of a class.

To create an object from a class, you must call a special method of the class, called "constructor." In OOP, a constructor is a special method of a class that enables you to create a new object of that class. When instantiated, the new object will have a default state, usually defined in the constructor method.

This is how you can create an object in Java:

Creating an object of the Tree class

Note that Tree() is the constructor of the Tree class. Thanks to it, you can create a Tree type object referenced by the myTree variable. Then, you can use the myTree reference to access the object's public attributes and methods.

Aristotle's Principles and OOP

As should be clear by now, there is a parallel between Aristotle's fundamental principles and object-oriented programming. But let's dig deeper into it.

First, a class defines certain characteristics that objects will have, just like potency shapes specific aspects and imposes some limitations. If a HumanBeing class does not have a fly() method, the HumanBeing objects will not have the possibility to fly. In other words, the class definition is determining some characteristics of the nature of the objects of that class, just as potency does.

Second, a class in act has the potency to become an object. Again, this object in act is just an object. At the same time, the object can change through the member functions coming from its class definition, which allows it to become something else in potency.

Thus, a Seed class has the potency to be instantiated as a Seed object, which has the possibility to become a Tree object through the grow() method. This logic corresponds exactly to the transition from act to power described by Aristotle.

Now, you might be wondering how this unexpected connection between Aristotle's philosophy and OOP is possible.

Aristotle was born 2,000 before the invention of the first programmable computer. Therefore, it is hard to imagine that he had object-oriented programming in mind when theorizing about potency and act. At the same time, Alan Kay may have based the programming paradigm on Aristotle's principles, but there are no statements or evidence that suggest this.

What must have happened is that Aristotle and Alan Kay had the same goals. They both wanted to find a way to represent reality and the evolution of objects and beings. Aristotle adopted the pair of terms "potency and act" to explain natural phenomena when devising his metaphysics. Similarly, Alan Kay invented the terms "class and object" to represent nature in a discrete digital world when introducing his programming paradigm.

Now, the question remains, "How many other correlations can be found between programming and philosophy?"

Conclusion

In this article, you learned how the universes of computer science and philosophy are not so far apart.

Aristotle's philosophy seems to be based on certain fundamental principles that can be associated with the building blocks of the object-oriented programming paradigm. In particular, Aristotle's concepts of power and act are close to OOP's concepts of class and object. Here, you saw how Aristotle's metaphysics and OOP are connected and why this may have happened.

Thanks for reading! I hope you found this article helpful.


The post "Aristotle Laid the Foundation for Object-Oriented Programming" appeared first on Writech.

Top comments (0)