Friday, June 5, 2009

Platonism and Object-Oriented Programming, or, A Post In Which I Get in Over My Head

I'm reading a book called Anathem by my favorite author Neal Stephenson. One of the things that I love about reading Stephenson is that he writes great, suspenseful, gripping fiction but he salts it heavily with discussions about some high-level topic. His books have dealt with cryptography, nanotechnology, and language. Anathem deals heavily in the philosophy of platonism. This may not seem like the stuff of a great novel, but I found it interesting enough to read up on it a bit.

According to the Stanford Encyclopedia of Philosophy (
Platonism is the view that there exist abstract (that is, non-spatial, non-temporal) objects. Because abstract objects are wholly non-spatiotemporal, it follows that they are also entirely non-physical (they do not exist in the physical world and are not made of physical stuff) and non-mental (they are not minds or ideas in minds; the are not disembodied souls, or Gods, or anything else along these lines).

Yeah, I have no idea either, but the examples help:

Consider the sentence ‘3 is prime’. This sentence seems to say something about a particular object, namely, the number 3. Just as the sentence ‘The moon is round’ says something about the moon, so too ‘3 is prime’ seems to say something about the number 3. But what is the number 3? There are a few different views that one might endorse here, but the platonist view is that 3 is an abstract object. On this view, 3 is a real and objective thing that, like the moon, exists independently of us and our thinking (i.e., it is not just an idea in our heads). But according to platonism, 3 is different from the moon in that it is not a physical object; it is wholly non-physical, non-mental, and causally inert, and it does not exist in space or time. One might put this metaphorically by saying that on the platonist view, numbers exist “in platonic heaven”. But we should not infer from this that according to platonism, numbers exist in a place; they do not, for the concept of a place is a physical, spatial concept. It is more accurate to say that on the platonist view, numbers exist (independently of us and our thoughts) but do not exist in space and time.

Similarly, many philosophers take a platonistic view of properties. Consider, for instance, the property of being red. According to the platonist view of properties, the property of redness exists independently of any red thing. There are red balls and red houses and red shirts, and these all exist in the physical world. But platonists about properties believe that in addition to these things, redness — the property itself — also exists, and according to platonists, this property is an abstract object. Ordinary red objects are said to exemplify or instantiate redness. Plato said that they participate in redness, but this suggests a causal relationship between red objects and redness, and again, contemporary platonists would reject this.

OK, so the basic idea is that there are these ideal things that exist independent of us, but that don't exist in space or time. Physical objects may instantiate those things in one form or another. Every equilateral triangle I draw instantiates the ideal form of an equilateral triangle.

So that's the platonism part of the post. What does that have to do with object-oriented programming? By this point, any OO programmer has figured it out, based on the word "instantiate." That's a very common OOP concept. For a non-programmer, let me try a brief intro to OOP. Let's suppose you're making a computer game with a bunch of little robots. Each of these robots has different properties (arms, legs, etc.) and different actions (move forward, left turn, right turn, etc.). You could each little robot separately by hand. That's fine but it takes time and you might make mistakes and one of your little robots won't work right. Or, you could code a robot "object" (hence "object" oriented programming). This robot "object" doesn't, in itself do anything. It just contains all the basic code each of your robots is going to need. Then, when you want to put an actual robot on the screen, you "instantiate" an instance of the robot object. Need another robot? Don't reinvent the wheel, just instantiate the robot object again.

So you see that object-oriented programming isn't just a convenient way of making computers do things, it also seems to embody an entire school of philosophy. I made this connection myself, but a google search for platonism and object-oriented programming showed me that it is a well-established connection.

At this point, I should note that when Neal Stephenson is not writing, he spends a lot of time coding. He even had a part time job as a coder, not for the money, but because he wanted to do something different with his brain than write fiction. So I have no doubt that Neal understands this connection and my only question is whether his interest in platonism came from his programming or whether he sort of "discovered" the connection the way I did.

Why blog about this? Partly because I was surprised to find something so pragmatic and functional as a computer programming language might embody a philosophical system and I wanted to share it. And partly because I think it says a lot about the nature of human creativity. Philosophers dream up an idea about the world; someone decides, "hey this might work as a programming language" and someone else decides, "hey this would be interesting to explore in a novel." It makes me wonder whether there are other approaches to programming based on other philosophies. It makes me wonder whether there might be wholly different ways of organizing computer technology that would work better if only we had a better philosophy to start with. And it reminds me of why novels and fiction are important because I wouldn't have learned any of this stuff from a philosophy book.


Erin said...

I think it's interesting that you describe programming languages as "pragmatic" and "functional." You're right, of course, in that that is what they have become, but they didn't start out that way.

Do you ever read anything by Noam Chomsky?

Anonymous said...

You're practicing Platonism yourself! :)

When you say that programming languages embody philosophical ideas it's almost as if you suggest there is such a thing as a philosophical idea which is instantiated in the programming language ^___^.

This comment is also Platonist in this sense, because it suggests there is an object called "Platonism" which is instantiated in your blog post (and my comment).

Of course, in reality this happens entirely in our heads.