Scala and the Play Framework, Wow!

As I continue down the path of testing out the Scala language and compatible web frameworks, I came across the Play Framework and all I can say is Wow! Play is a very nice polished framework, which just feels right to me. I had the app up running and doing everything I wanted in a fraction of the time on any other technology I tested. Everything just worked, I didn’t have to fuss with a bunch of settings, config files, library versions, or anything.

Play is a Java framework and with the 1.1 release (not final) they have added Scala support. They claim Scala is still experimental but it works better than most complete technologies I’ve tested recently. The console interface for installing, running and managing the app works great. One of the most impressive pieces is the testing framework which combines Selenium and Unit testing and managed through the browser.

I literally made more progress with Play in an hour than I did with everything else which took days or weeks. For example, after two weeks with StringTemplate and Scalasti I am still not able to loop through a result set within a template.

Structure and Features

The Play structure is very intuitive and works well with the way I think. I come from a heavy PHP background and have been developing on a large Zend Framework app for the past 4+ years. We built our app structure off the Rails structure and Play continues along the same project structure (app, controllers, models, views). I don’t come from a heavy Java background, so the Maven project hierarchy has never really quite gelled with me.

A few key features of Play:

  • Automatic Compiling and Reloading of Everything
  • Contextual and Relevant Error Codes
  • Testing Framework baked in
  • Fast getting started time
  • Good Documentation and Tutorials
  • I haven’t used the Play ORM yet, but I don’t really use Zend’s either. Most apps and queries tend to require a little more customization and optimizations than any ORM can give. I’m sure I’ll check it out, maybe they’ll surprise me there too.

    Quick Start

    Download the Play Framework 1.1 nightly build from: download.playframework.com

    I downloaded and installed to: /opt/play. Add the directory you extracted play to your PATH.

    Create New App:

    play new testapp --with scala

    oops.. you haven’t installed Scala Module yet, it’s as simple as

    play install scala

    Try to create your app again and it will generate the app structure and a working demo app.

    Run App:

    play run testapp

    or from within the testapp directory just run

    play run

    A great little bonus is Play has built-in documentation, just go to a running instance: http://localhost:9000/@documentation — which is so useful, since I don’t always have an internet connection, for example during a train ride from SF to Chicago.

    Kudos to the Play team, my search for a Scala Framework might be complete.

    Further Reading: