Monday 3 December 2012

Play!ng Around

Since learning Scala and looking at new technologies, I'd parked the Swing project, described previously.  It turns out that writing UI delegates is quite tedious, especially when it doesn't seem to fit in to the existing framework.

My new project is a toy application using the Play! Framework, part of the Typesafe stack. This is a Java and Scala API for web applications and it looks a lot like Rails, from the little amount I know about Rails.

My toy project is a calendar/appointment booking site and I've chosen to write it in Scala. The Play! framework also supports writing your CSS in less (www.lesscss.org) so I thought I'd give that a go too.

The first thing to notice is that Play! uses sbt heavily to control the project lifecycle; the bundled "play" executable is simply a wrapper around sbt, including additional Play! modules. This, IMO is both a blessing an a curse; in my limited experience of developing in Scala, I have always found sbt the hardest part of the learning. This was also my experience here. The thing is that a default Play! application creates a project/Build.scala project configuration file. Unfortunately, this is a different format than the build.sbt file described in all the sbt tutorials. This caused me some level of confusion when attempting to add the ScalaTest library to my project; resolved by adding a build.sbt file with a simple libraryDependencies definition:


libraryDependencies += "org.scalatest" %% "scalatest" % "1.8" % "test"

From there I was able to create a simple web page that displayed a grid, which I hope to make look like a calendar page (month view) very soon.