The REST (Representational State Transfer) is a hot topic in IT development world at the moment. Some see it as complimentary to SOAP, XML-RPC etc others as a replacement; and even within the REST community there are various flavours: REST-Purists who only accept the four basic http verbs (PUT, GET, POST, DELETE) which map generally onto the Create,Read, Update and Delete (CRUD) operations of the database world; the REST-LIKE group who are more pragmatic since there are situations where these verbs don’t cleanly map to the problem domain AND also can use other aspects of the HTTP protocol such as cookies for session management.

REST has really taken off with AJAX and the new slick interfaces such as Google Maps. due to its sheer simplicity unlike SOAP and to some degree XML-RPC which generally involve translating client format – to say SOAP format which on the target server is then translated back into some other server internal format this is a recipie for slowness.

Where do I stand? well with most things I am not a religious fundamentalist so I tend towards the REST-Like group. The basic four verbs work for about 80% of the development I do, but you do have to be flexible. I do like using the excellent XStream library which frees me from the XSD/DTD->Java step and allows me to serialize complex POJO’s to and from XML with three lines of code (the library does not do “elements” though) so is simple and easy to use – gets my vote and I’m a fan of OCCAM.

One thing I have noticed within the JAVA world is the assumption that REST = web application by implication servlets/JSP. This is simply not true. Yes HTTP and HTTPS are the back-bones of the web, but it is only one part of the web. HTTP is not HTML – even though is can return HTML, XML or any other MIME type; and it does not need a web server to run. I have to admit that most libraries that allow you implement REST under JAVA are based on servlets (GOMBA, and RESTLet) so are tied to jsp/servlet containers; this is why there is mindset link in the Java community between REST and the WEB or more specifically between REST and Java Servlets.

I find it a bit irksome in that you don’t need Tomcat or a full Jetty engine to implement a REST server within you application or application server – and often you get a much better performance and smaller memory footprint if you don’t. For example I have implemented a REST application server that does not use servlets. A full Jetty server (6.0rc1) takes up around 21MB of my Linux box and that does not include my application. If I however just take the JETTY core which provides the fast networking library code, dump servlets, JSP and HTML handlers and add Spring and XStream and my app code I can generally build a full application in under 5MB. You might think that is not much – but in applicance development, PDA’s, and other embedded development every byte and processor cycle counts, and with Apache’s Daemon its easy to develop Linux and Windows services that start up at system boot time.
A good pod cast I have found discussing REST is the ever excellent Java Posse groups pod-cast #76