An Architect's View

CFML, Clojure, Software Design, Frameworks and more...

An Architect's View

Grails - a first look

February 10, 2008 ·

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

  • 1 Kurt Wiersma // Feb 10, 2008 at 5:04 PM

    There are three things that I think I think will help Groovy and Grails become a huge force in the Java space.

    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've not used Groovy outside of a couple of times, but I didn't honestly notice much difference between the syntaxes. What sticks out at you? (I like the get/set magic with Java methods, but I hate it for Groovy methods.)

    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

    For what it's worth, I've done a proof-of-concept at work comparing JRuby on Rails and Groovy and Grails and blogged about it (http://www.brianlegros.com/blog/2008/01/20/proof-of-concept-learning-groovy-grails-jruby-and-rails/).

    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

    @Sammy, there's a lot of little things. Mostly I don't languages that use punctuation to indicate scopes or types - Ruby uses @ for class instance variables and @@ for class variables and $ for globals, and it uses < for extends with class. I also don't like the class / end and def / end syntax - { } seems more natural to me. There's a lot of other things that just annoy me about Ruby syntax.

    But yeah, it'll be interested to see what happens with Groovy.
  • 5 Sean Corfield // Feb 10, 2008 at 8:11 PM

    @Brian, thanks for the link - excellent reading and it's good to hear someone with more experience building software with both languages / frameworks articulating many of the things that I suspected in terms of comparison. Lots of interesting links in your blog post too - I think I just spent an hour reading all that!
  • 6 BRD // Feb 10, 2008 at 10:07 PM

    Grails looks nice and the fact that it's built on extremely pervasive frameworks like Spring and Hibernate makes a lot of sense.

    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

    @Sean - I'm glad you enjoyed the write-up. If you ever want to pow-wow on the topic, just let me know. I'm always up for working with the Groovy/Grails.
  • 8 Sean Corfield // Feb 11, 2008 at 8:04 AM

    @BRD, statistics are whatever you make of them:

    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

    http://www.indeed.com/jobtrends?q=python%2C+ruby+or+ror+or+rails%2C+groovy+or+grails%2C+php%2C+perl&l=&relative=1

    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

    http://www.indeed.com/jobtrends?q=python%2C+ruby+or+ror+or+rails%2C+groovy+or+grails%2C+php%2C+perl

    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

    @Brian, feel free to add me on IM :)

    seancorfield on AIM/Gtalk(@gmail.com)/MSN(@hotmail.com)/Skype/YIM
  • 12 Maxim Porges // Feb 11, 2008 at 6:32 PM

    Hey Sean,

    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

    no matter ruby extenting, it can never ever replace coldfusion..
  • 14 Jason West // Mar 6, 2008 at 8:34 AM

    Actually GRAILS or RoR (Ruby on Rails) are two different frameworks that "could" replace the ColdFusion deployments in the future. As long IT shops are able to get past the Corporate fears of OpenSource technologies (which most have) these frameworks are faster deployments and easier maintenance then we currently see with ColdFusion. I have been developing in ColdFusion since ver 3 (Allaire... miss the name) and have always appreciated the quickness or writing applications in the language. But recently I have been dabbling in the Rails frameworks and I have to say that I now am leaning more towards them with new projects. Just my 2 Cents. :-)
  • 15 Henry Ho // Feb 8, 2009 at 4:58 AM

    Any update to the Scripting for ColdFusion 8 project?

    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

    @Henry, with Barney actively developing CFGroovy, I don't see much point in creating a competing project. I'd be more inclined to collaborate with him on CFGroovy if there was anything I felt it didn't do for me.
  • 17 Lus Colorado // Feb 1, 2011 at 8:28 AM

    Groovy on Grails is still far from perfect. It's main defect is Groovy. Groovy, personally speaking, threw away the water with the baby. Typing is almost nonexistent, even when the insist that it is "strong typed". It has to be coded carefully, or you'll have a hard to read, hard to maintain, write-only application.

    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

    @Lus, have you looked at Scala and Lift? (or perhaps Play?)