Archive for February, 2008

Platonic REST

Once, in an ancient past, I studied philosophy for a couple of years. At the time, I could not really appreciate the subject, so I quit and switched to Artificial Intelligence. In retrospect, I think I might have been too young to appreciate it fully. Having a bit more experience in life sure helps.

That said, I don’t think it was a waste of time. I learned a great deal about logic, proper argumentation, and of course the history of philosophy. The latter might seem impractical, but it sometimes does apply, even in the field I’m currently working in.

Plato

Take Plato, for instance. Together with Socrates and Aristotle, he is one of the founders of Western culture. Famous for writing up the Socrates dialogues, he also wrote some works of his own, one of which is The Republic. In this work, he describes his famous Allegory of the Cave, which goes something like this:

Imagine prisoners, who have been chained since their childhood deep inside a cave: not only are their limbs immobilized by the chains; their heads are chained in one direction as well so that their gaze is fixed on a wall.

Behind the prisoners is an enormous fire, and between the fire and the prisoners is a raised walkway, along which puppets of various animals, plants, and other things are moved along. The puppets cast shadows on the wall, and the prisoners watch these shadows. When one of the puppet-carriers speaks, an echo against the wall causes the prisoners to believe that the words come from the shadows.

The prisoners engage in what appears to us to be a game: naming the shapes as they come by. This, however, is the only reality that they know, even though they are seeing merely shadows of objects. They are thus conditioned to judge the quality of one another by their skill in quickly naming the shapes and dislike those who play poorly.

There are many interpretations of this allegory, but for me it has always been about not knowing the true reality of things; we only see shadows cast on the cave wall.

REST

Fast-forward a couple of thousand years, and let’s look at REST, the key design principles of which are:

  • Identifiable Resources
  • Uniform interface
  • Resource representations
  • Stateless conversation
  • Hypermedia

Resources are identified by a unique identifier (a URI), and you interact with the resources through a uniform interface with well-defined operations (i.e. GET, POST, etc.). Using these operations, you create representations of resources (such as a text/html representation, or application/xml). Typically, these representations contain links, making up hypermedia.

What does this have to do with Plato? Well, in REST there is no one true representation of a resource. There can be many of them, each of which is as important as the other. In other words, the representation is just a shadow of the resource, cast of the cave wall…

Comments (1)