Skip to content
philosophyprogramming

Schopenhauer & Object Oriented Programming

How a 19th century crank (possibly) anticipated Java.

2020 has been a wild ride to say the least. January alone started with a million Hong Kong protesters on a New Year’s Day march, the Australian bush catching fire (ironic considering UN declared it the International Year of Plant Health), the assassination of an Iranian major general by a US drone, prompting speculations about a new war, and if that wasn’t enough, COVID-19 came along, as of now with 28.8 million infections, 900k+ dead, mass lockdowns, and the largest economic recession since the Great Depression. Honestly, so much bad stuff has happened this year that just writing it would probably trigger someone’s PTSD. Instead I leave you with this only slightly depressing recap & video. After all, images are worth a thousand words.

Maybe prompted by this confusion at the state of the world, I have been thinking a lot about philosophy these days. Out of the many people to write on the subject, there is one that feels somewhat fitting for our situation, Arthur Schopenhauer.

A notoriously pessimistic philosopher, Schopenhauer formed his system of thought from the teachings of Plato, Kant and the Indian Upanishads. He drew from the first two the idea that what we experience as the world is not actual reality and supplemented it with Indian concept of Maya, a veil that hides the true nature of the world from us. His idea of the world as will and representation is a metaphysical system that considers Plato’s “Ideas” and Kant’s “things-in-themselves” to be the same thing, an underlying structure to existence that we cannot see directly, but rather only their representations. But his idea of the will took it one step further. He said there was only one will, an undivided entity that drove all things in the universe through ceaseless striving towards its goal.

He was also strongly influenced by Buddhist thought, claiming that all human suffering came from attachment to desires. To Schopenhauer, desire was pain that persisted until it was satisfied. Satisfaction itself was simply the neutral lack of desire as opposed to a positive value such as joy. In essence, Schopenhauer thought that life spent in pursuit of desire was constant pain, with only short periods of boredom as reprieve, a negative-sum game. Another striking idea of his is that we live in the worst possible sustainable world.

As compelling as his pessimism is, especially in 2020, over the past couple of days I was more interested in his metaphysical system of will and representation, specifically how similar it sounded to Object Oriented Programming. OOP is a computer programming model that puts emphasis on data in a program. The class could be the will and all the objects you create from it could be manifestations, or representations, of that will.

Consider the two boxes below. The first is the world as representation. The second is the world as will. The circle in the center is the subject — you can “simulate” its will by dragging and releasing it.

class Circle {
    constructor(x, y) {
        this.position = [x, y]
        this.velocity = [0, 0]
    }
    update() {
        this.position[0] += this.velocity[0]
        this.position[1] += this.velocity[1]
        if (this.hitsUniverseBoundary())
            this.bounceOff()
    }
}

var universe = []
universe.push(new Circle(200, 200))

That circle must be filled with existential dread from being alone. Let’s give him a friend. Notice that they are both subject to the same “will” despite being individual objects with different starting positions.

Another useful aspect of OOP is inheritance. Inheritance is the idea that since different objects can have many attributes in common, we can create a class that contains them and limit the classes of the objects themselves to describe only the specific differences. Eerily similar to the concept of the will coming in gradations.

In the code below, we have a hierarchy: Circle extended by Animal (with lifespan and reproduction), extended by Human (with intelligence and the urge to hunt). You can control the humans by dragging an animal around their vicinity.

You can see the “worst possible sustainable world” idea here as well. If animals couldn’t propagate, or were killed before they did, they would be wiped out in a minute. But when we ensure there is always an animal alive, we allow the cycle to go on indefinitely.

A more interesting take is that Schopenhauer isn’t necessarily similar to OOP, but to simulation theory in general. Sure enough, a short google search turns up this article making the same observation, and a whole paper called The World as Will and the Matrix as Representation.

So instead, let’s stick to philosophy and try to make sense of this world. The first and foremost problem is free will. How can an individual have it if will itself is an unchanging entity that lies on a cosmic scale?

“Man can do what he wills, but cannot will what he wills.” — Einstein

Or can we? This is just random speculation on my part, but what if will isn’t constant? There is no sufficient reason to say it is. What if the more we understand the will, be it through art, spirituality or science, the closer we get to changing it?

In programming terms: can an object change its own source code, its class? Can we make a meta-program that can edit itself? Lisp can. So can JavaScript, with prototype (and historically, eval).1

Here, we let our humans become mages. They will bumble around the world like hapless idiots until they interact with each other. These interactions raise their “mage level,” unlocking spells that twist the world itself.

Isn’t that amazing? This is where Schopenhauer and I part ways. Far from being a pessimist, I believe that we are destined for great things. We will will the will (say that three times fast) through our desire to better ourselves, and in doing so, change this negative-sum world into a positive one. If Schopenhauer bumped into you on the street, he would check his pockets and try to dissuade you from suing. I would apologize and give you a wink.

How would you like to be a Level 5 Mage?

Footnotes

  1. I’ve since updated the playground component to use sandboxed iframes instead of eval — same effect, no security footgun. See the colophon.