Monday, June 30, 2008

First Official Release of Sling

The Apache Sling team recently announced the first official release of Sling. Now you can download some nicely packaged Sling bundles to play around with.

I have been experimenting with the Sling/CRX bundle that came with Day Software's JCR Cup 2008 competition (entries due midnight September, 30) and was really impressed by what I saw.

Sling allows you to write applications on top of the JCR using either server side or client side Javascript. On the server side, you can create Java Script Templates (ESP files) that give you access to the full JCR API. Templates are stored in the repository and called using an elegant MVC request processing framework. Templates can be called directly, or can be associated with content types and executed when an asset of that time is requested. As you might expect from Roy Fielding's employer, it is all very REST. For client-side scripting, you just import a Javascript file called sling.js and you get methods like "Sling.getContent" (which gives you an array of Javascript objects).

Despite the fact that Sling is still an incubation project, it is fairly mature and robust. Day's upcoming release of Communiqué (version 5) uses Sling extensively. I envision Sling being used in a presentation tier where pages are statically rendered (baked) from content in the JCR and Sling is used to power dynamic AJAX overlays using content from replicated JCR workspaces.

I really like the fact that logic is written in an interpreted language like Javascript. Development and deployment is faster when you take out the compilation step. Furthermore, Sling is built as OSGi (using Apache Felix) bundles so it is more modular and flexible than a typical monolithic Java web application.

The CRX (or the free Apache JackRabbit implementation of the JCR) and Sling should be considered along side Alfresco with its elegant Web Scripts (which also uses Javascript as a scripting language). Alfresco has some nice virtualization features but there may be a higher level of lock-in to the Alfresco API's. Alfresco has a user-oriented user interface while the CRX only has a JCR browser which is really only intended for administrators. However, in both cases, you will probably want to develop your own user interfaces because Alfresco's current WCM UI is not optimized for managing web content (improvements are scheduled for mid 2009 - interestingly, the Alfresco team is calling these enhancements "project Slingshot).