Saturday, May 30, 2009

Getting a lift from Lift

"Have you heard about Scala and Lift?" my friend Jim asked me a couple of weeks ago at lunch. He had mentioned Scala in earlier conversations, although I had not looked into the language. Earlier in the week I had been given a new assignment to put together a demo web application to manage server configuration information, so the timing of Jim's comments could not have been better.

I had considered what language/framework to use for the demo, but none of them in my toolbox had appealed to me. The general requirements for the webapp ran something like this: gather data from Linux servers, organize it, store it, and present it via a webapp. Gathering and organizing the data presented little difficulty; ssh and various commands such as 'cat /proc/cpuinfo', combined with a Perl program would work for this. Storing the data in a relational database would solve the storage requirement. That left presenting the data via a webapp.

I had two choices at my disposal, Perl and Java.

I like Perl for many small text processing jobs. It provides a tremendous number of ways to seriously mangle text. But it can trip you up since it doesn't do many checks until run-time. Thus you spend many hours debugging your application. In short, I like to use Perl for small programs, but I'm wary of using it when the scope can creep and the application grows beyond 'small'.

Java provides compile-time checks and people have used it for very large applications, but the frameworks with which to build web applications seem clunky to me. Modern IDEs ameliorate this clunkiness, but I have yet to get beyond emacs. There's probably another posting in here. So using Java did not encourage me either.

Enter Scala and Lift. Scala combines functional programming constructs with the mature Java object-oriented technology to provide the best of both worlds. It also includes XML in the language. It runs on the Java virtual machine and allows a programmer to use Java classes natively. Wow!

Lift provides a web application framework using Scala. It cleanly separates the underlying data model from the presentation so that you can change the appearance of your web pages without having to recode anything.

In two and a half weeks I have learned enough about Scala and Lift to complete the web application to the point where I can let others play with it. I've had several ideas for web applications over the years, but the amount of effort needed to realize them has discouraged me from starting them. With this new framework the effort should be much less. Check back in a couple of weeks on my progress.

Resources



www.scala-lang.org Scala, the language.

www.liftweb.net Lift, the web application framework.
Creative Commons License
This work by Steve Roggenkamp is licensed under a Creative Commons Attribution 3.0 Unported License.