I recently had the opportunity to work with Scala and Lift to develop a little demo/sample application to showcase their capabilities. We built a Scala 2.7+Lift 1.x application that used the REST interfaces of a Java-based server that was running on SAP NetWeaver CE 7.2 to run a webshop e-commerce scenario. Since Scala has been gathering a lot of attention lately, I have written down some of observations below, from the point of view of someone who isn't a Java nor a Scala expert (I work in IT consulting but I don't do development)
Regarding Scala:
- Scala as a language is more concise and expressive than Java in some areas, so that you write less to achieve the same or more than in Java.
- Closures and nested functions are rather useful
- The fact that Scala is a functional language also helps to write shorter code; something that would be a loop in Java with a bunch of lines of code inside the loop can be solved with a call to a function over a set/list with a closure or function as one of the arguments (e.g.: List.flatMap, which you'll be using a lot in Lift)
- Traits as first class citizens are nice if you're used to mix-ins in Ruby or Python (more information: http://www.scala-lang.org/node/126)
- Scala code can seamlessly call Java code. However, due to some of the extra features that Scala has over Java (traits, generics, methods with any name, etc) it may not always be straightforward to call Scala code from Java.
- Actors as a lightweight pseudo-thread implementation are nice, and Lift makes some good uses of them
- Existing classes/libraries can be extended with new functionality without accessing their source code or even extending existing objects or interfaces, the so-called "Pimp my library" pattern, implemented using Scala's support for implicits
While some of these could be placed in the "syntatic sugar" bin, I found that during development they add an additional level of convenience to the language. It'll be interesting to see if Java adopts any of the key features from Scala over the next releases.
If interested in more details, there's a nice tour of the language features here: http://www.scala-lang.org/node/104
Lift is a web development framework that has been gathering some attention lately. Not only because it is built on top of one of the "hot" languages at the moment, but also because it adopted some of the best features of a bunch of different frameworks. Our application was started on top of Lift 1.1, but was moved later on to Lift 2.0 even though we only used one very small feature from the framework.
- Lift uses a "view first" approach so most the program logic will go into the so-called "snippets", which are nothing more than Scala classes that are called from XHTML templates. It takes some time to let go of the concept of "where is my controller??" but after that it works well
- Lift comes with its own data persistence layer, Mapper, and provides some nice functionality over it such automatic validation and the CRUDify trait, which automatically gives your model classes create/read/update/delete pages and functionality. It is also possible to use JPA but then you're somewhat on your own. There's a good example of a Lift application using JPA for their persistance layer here: http://github.com/rmuri/TravelCompanionScala
- There's a lot of ready-made functionality available in Lift out of the box: user handling and authentication (based on Mapper), sitemaps, permission-based application menu creation and handling, etc
- It is ridiculously easy to add Ajax functionality to your applications without writing a single line of Javascript code; all the plumbing behind the scenes is taken care of by Lift. On the other hand, adding custom Javascript functionality to a Lift application may take some time
- Comet functionality based on Scala's Actors, where specific areas of your page can update asynchronously and independently from the rest of the page
There's of course many more things about Lift but these are the ones I would highlight after our brief experience.
Some of the Lift features can be tested online here: http://demo.liftweb.net/. The source code for all these demos is available from Lift's github repository here: http://github.com/lift/lift/tree/master/examples.