Grails - a first look
February 10, 2008 · 18 Comments
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.
Tags: coldfusion · grails

18 responses so far ↓
1 Kurt Wiersma // Feb 10, 2008 at 5:04 PM
1. Groovy syntax is more java like. I prefer it to Ruby.
2. Groovy can take advantage of existing java code. You can do this with JRuby as well but I don't know if the integration is as good.
3. With you Grails and jetty you supposedly can get pretty close to the "hot deploy" features that CF developers expect. You can update a groovy file and then hit reload in your browser and the changes are there. No more worrying about class loading.
Another things I like about Grails is it is powered by Hibernate and Spring verses Rails with uses ActiveRecord.
2 Sammy Larbi // Feb 10, 2008 at 6:36 PM
I think the integration with Java is still a lot better than JRuby, but from what I know, the JRuby guys are trying to make that the number one priority (or, I could be a release behind on that - so much information comes through my reader now that I find it hard to remember timing information)
I'm looking forward to seeing great things happen with Groovy, in any case.
3 Brian LeGros // Feb 10, 2008 at 7:14 PM
Groovy makes the stress that comes with Java programming subside quite a bit (especially for CF programmers who have dabbled with Java). GroovyBuilders and the MOP layer alone make it worth the look.
As far as a framework, Grails has a great ORM tool called GORM which is a Groovy wrapper for Hibernate making Hibernate a lot easier to use. There is also a growing plugin community that have produced some amazing tools to make JEE integration extremely easy; check out the JMS plugin to see how easy its gotten. Additionally, someone has even released a Flex plugin for Grails that makes bundling Grails and Flex into a WAR just as simple as typing "grails war".
Groovy and Grails are definitely worth exploring, IMO. JRuby on Rails is great to work with, but the JEE integration support is no where near what Grails promises to deliver which is really important to me.
4 Sean Corfield // Feb 10, 2008 at 7:16 PM
But yeah, it'll be interested to see what happens with Groovy.
5 Sean Corfield // Feb 10, 2008 at 8:11 PM
6 BRD // Feb 10, 2008 at 10:07 PM
As for Ruby verus ColdFusion, well, this chart is a little telling...
http://www.indeed.com/jobtrends?q=%22cold+fusion%22+or+coldfusion%2C+ruby&l=
7 Brian LeGros // Feb 11, 2008 at 6:21 AM
8 Sean Corfield // Feb 11, 2008 at 8:04 AM
http://www.indeed.com/jobtrends?q=java%2C+coldfusion+or+%22cold+fusion%22%2C+perl&l=&relative=1
That shows that the job markets for Java, Perl and ColdFusion are all pretty stable (as expected - they're all mature, stable technologies).
9 Sean Corfield // Feb 11, 2008 at 8:04 AM
That shows the "new" scripting languages are all growing compared to Perl and that Python, Ruby and Groovy are all outstripping PHP in terms of growth, with a huge spurt of Groovy/Grails popularity recently. Again, no surprises there. The "new kids" are still growing into their market - because they're new.
10 Sean Corfield // Feb 11, 2008 at 8:05 AM
That shows that Perl is still far, far, more popular than the other scripting languages, even PHP. Again, no surprises - Perl is a mature, stable technology.
11 Sean Corfield // Feb 11, 2008 at 8:06 AM
seancorfield on AIM/Gtalk(@gmail.com)/MSN(@hotmail.com)/Skype/YIM
12 Maxim Porges // Feb 11, 2008 at 6:32 PM
I've been pretty impressed by what I've seen out of the Rails community. Ruby's syntax is definitely "take it or leave it", although I must say I like the terseness and flexibility of the language.
I was a little sad when LeGros's foray in to Grails didn't pan out the way we had hoped, since the learning curve would have been shorter for our web team to pick up than it will be for Ruby (after all, we're primarily a Java shop). However, having seen the current state of the JRuby implementation I'm certainly not disappointed that we're going to be leaving CF for it.
- max
13 mat // Feb 13, 2008 at 7:15 AM
14 Jason West // Mar 6, 2008 at 8:34 AM
15 Henry Ho // Feb 8, 2009 at 4:58 AM
Are you still considering adding Groovy support?
If so, do you think it will work better, similar, or worse than the CFGroovy project?
Thanks!
16 Sean Corfield // Feb 8, 2009 at 11:32 AM
17 Lus Colorado // Feb 1, 2011 at 8:28 AM
And, ironically, Groovy helps a lot to do OOP, but, like PHP, it is just too easy to write bad code.
Groovy has many advantages and advances, but weak typing is a real turn off.
18 Sean Corfield // Feb 1, 2011 at 5:28 PM
Leave a Comment