Rebel With a Cause
Thursday, October 30, 2003
Sven Van Caekenberghe has written an interesting case study (Rebel With A Cause) about creating a web site using Common Lisp. The fact that he uses CL isn't the most interesting part of the article though - he also uses Object Prevalence. Object Prevalence is built around the following key ideas:
- Most databases are only a couple of hundreds of megabytes big, often even less.
- Most computers can easily take a couple of hundreds of megabytes of data in RAM, big servers can hold many gigabytes.
- Mapping objects to databases is at least tedious and time consuming, but often also complex and error prone.
- Let's throw away the database and just consider the domain model objects as the database.
- Let's make sure we can serialize and deserialize our objects to and from a some presistent medium such as a file system.
- If we store our complete set of domain model objects to a persistent medium we create a snapshot.
- We query by using the data structure manipulation functionality of our programming language, running from RAM, queries will be extremely fast.
- Let's agree to only change our object model using transaction objects that combine the data and the functionality to execute the transaction.
- In order to preserve the ACID properties of our system, we log each transaction to some persistent medium by serializing it after we execute it. The is called the transaction log.
- When the system goes down (intentionally or unintentionally) we restore its latest state by first reading in the latest snapshot and by re-executing each transaction from the transaction log.
- Transactions must be deterministic and re-entrant (so they also need to record the current time if necessary).
- In a multi-threaded system, transactions are globally serialized.
"It is our opinion that object prevalence makes a lot of sense in a dynamic, interactive language like Common Lisp (much more sense than it does for Java). A Lisp read-eval-print loop together with Lisp's strong datastructures and manipulation functions makes for a much better alternative to SQL for querying and database maintenance. Without such a capability, using object prevalence will be a lot harder. Also, the serialization to XML helps a lot in making the system maintainable. XML and Common Lisp are much more resilent to ongoing changes in the object model than for example native Java serialization. "

