A First Look At Grails

Wednesday, February 13, 2008 by Mistlee

A First Look At Grails

By Sean Corfield

There's still a lot of buzz about Ruby on Rails and I've played around with it but I really don't like the Ruby syntax.

I've tried a few different Rails packages and just find the experience... clunky. Lots of people are very excited about Rails and Ruby in general, especially with JRuby (Ruby for Java) now running Rails. In fact, Maxim Porges thinks JRuby has taken ColdFusion's place as the new web productivity layer for Java, after watching Charles Nutter demo JRuby at the acts_as_conference Rails conference recently in Florida.

Another scripting language that people seem to like is Groovy and there is now a Rails-like framework for Groovy called, unsurprisingly, Grails. Derek Perez likes Groovy and has asked me several times to add support for Groovy to my Scripting for ColdFusion 8 project. Raffaele Castagno, an Italian Groovy fan, even sent me custom tags and instructions for adding it to the project back in August last year but I never got around to it. Then Dave Ross said the other night that he thought Grails was going to do very well for Java developers who don't like Ruby's syntax. Since that was my main objection, I figured it was a good time to actually look at Grails.

The Grails site has a simple installation page with two options: download and install or install from Subversion. The latter sounded like fun for a Sunday afternoon so I checked the code out from codehaus.org and typed ant. 17 minutes later, I had a pristine installation of Grails from the head of SVN. Time to write my first Grails app!


The Grails site also has a simple Quick Start: grails create-app, grails create-domain-class, grails create-controller. A couple of small edits to the generated code and then fire up Grails and run the app in the browser. It all went very smoothly, exactly as the Quick Start showed.

The first thing that struck me about the running example - after seeing the Rails scaffolding and the Model-Glue scaffolding - is just how pretty the default scaffolding is! Nicely styled output (with CSS), icons for create / edit / delete, a sortable list view (the screencasts on the Grails site were clearly made with an earlier, less sophisticated, version of the scaffolding).

The syntax is definitely cleaner than Ruby (in my opinion) and the structure of the application feels very Java-like and, thus, more familiar to me than the Rails approach. It's probably nice enough that I might actually continue playing with Grails (unlike my experience with Rails).

There are tutorials on integrating Grails with Hibernate and Spring, which will also be more of a match to what I'm used to in ColdFusion (with Transfer and ColdSpring at the heart of all my projects). You can easily create a WAR for deployment of the (compiled) application to a Java app server (technically any Servlet container) so, in theory, you can deploy Grails apps to a JRun instance to run alongside ColdFusion.




Delivering IT Solutions DevWebProAU News Archives About Us Feedback DevWebProAU Home Page About Article Archive News Downloads WebProWorld Forums Jayde iEntry Advertise Contact

0 comments: