Tuesday, September 27, 2011

From NoSQL to NoServer

I attended an interesting presentation recently on CouchDB, a document store database that helped make the term NoSQL famous. One of the interesting ideas discussed is the idea of CouchApps: pure JavaScript/HTML applications working with and interacting exclusively with CouchDB. So not only do you not need a relational database, you can dump your application server too.

I think this is a natural progression given how the browser and CouchDB complement each other. CouchDB natively speaks JSON over HTTP. Browsers speak fluent JSON and HTTP. What else do you need? Performance is likely not an issue in many cases: browser JavaScript engines have become very fast, and CouchDB itself is quite scalable. I doubt that a CouchApp is the best approach in every conceivable application, but it sure looks like a viable architecture in some areas. For example, think of where the application server is a thin CRUD layer that translates between the browser and the database: you know, those small PHP scripts whose job is to speak HTML to the browser and SQL to the database. When browsers can speak natively to CouchDB, this translation work may be redundant. Fine-grain security might be an issue, though.

What I do find amusing is the CouchApp advocacy stuff that calls the traditional 3-tier architecture the "bad old days" of years past. This is amusing because CouchApp is basically a reincarnation of the classic 2-tier ("client server") architecture of even more years past. A classic architecture consisting of a rich client talking to a database backend, the days 2-tier reigned supreme would also be a period 3-tier developers call the "bad old days". Of course, the rich client used to be written in something like Visual Basic or Delphi and the database would be an SQL database, but the idea and division of logic is the same. Like the classic 2-tier apps, a CouchApp would have to divide the business logic between the client and the database.

What might make things more interesting this time round is that JavaScript code on the browser is much easier to read and modify than compiled binaries. You can selectively insert or replace JavaScript code: the FireBug console, or a bookmarklet or two, makes this trivial. If CouchApps take off, the end user will be empowered to do weird and wonderful things to an application that the developer may not have dreamed of.


  1. Wonderful blog & good post.Its really helpful for me, awaiting for more new post. Keep Blogging!

    Blackberry Development

  2. Thank you very much for posting this great information! I am looking forward to seeing more posts about this!

    iPhone Application Development

  3. Nicely presented information in this post, I prefer to read this kind of stuff. The quality of content is fine and the conclusion is good.

    Thanks for the post.
    iPhone Application Programmer