Wednesday, 26 December 2007
I Tried Grails!
« Adding Selenium Support To Appfuse | MainI finally tried Grails. The Groovy based knock off of Ruby on Rails. I had earlier started reading " JRuby on Rails : Web 2.0 Projects" but just felt that Ruby was too different from Java to get excited about. I felt like Grails fit in much more seamlessly into the Java ecosystem than JRuby and I didn't feel like I was missing out on the neater features of JRuby. More importantly, having trusty old Spring and Hibernate right there if I needed them was certainly reassuring.
I started out by first by reading "Getting Started With Grails". After I completed this book I jumped in and wrote a variation of an application I wrote earlier in Tapestry 4 which is a simple application that asks a bunch of categorized yes/no questions and calculates the yes answers in each category and saves them to a database which is retrievable later. IMHO, I felt doing the project in Tapestry 4 did not have any advantages for a small project like this. Here's some metrics:
Tapestry 4 Java Code Lines : 575
Grails Code Lines: 255
Grails Code Lines Excluding Auto Generated Configs and tests: 86 (Wow!)
Things you don't need to deal with in a basic Grails app that you do with Tapestry 4 :Ant build file, Hibernate Config, Tapestry Application Descriptor, Component Specification (jwc), any additional libs except for the database jar.
I have to level some criticisms at Grails though. First, it tends to give some strange error messages when the environment isn't configured just right or you do something wrong. Also, I had some trouble figuring out where to put stuff if I wanted it to be on the classpath. Lastly the IDE integration is weaker than pure Java so autocomplete was mostly a manual process not assisted by the IDE. Being able to quickly re-load and see changes compensates for this.
One more note. As a Java developer I am a little prejudiced against loosely typed languages but Grails alleviates my fears by allowing me to easily interface with regular Java components via Spring.
All in All, I think Grails is the next big thing in Java development. I have completed major projects professionally in Tapestry, Struts, and JSF and I feel like Grails just blows them all out of the water right now, especially for smaller projects. I am going to try to use Grails on a much larger project to see how it works in that context. The backend of my larger project is all in Java/Spring and uses some pretty tricky Hibernate stuff but I think that Grails will be great as a quick and agile web tier framework.
Technorati Tags: grails java tapestry web mvc frameworks
[Trackback URL for this entry]
You really need code completion for 86 lines of code? Just kidding ;)
I feel the exact same way about Grails, it is the next big thing.
Rails showed us the path, but we can walk the journey on our own.
I'm just wondering how this is comparable with Hibernate and new Spring MVC (2.5) annotation support? Lots of those configuration files will vanish!
Especially Hibernate has a very good Convention Over Configuration support...
I also recently tried grails, but became concerned at the amount of work required to make the "default" functionality more usable. Hopefully the defaults become more usable soon. Also interested to know how it works on a big project with lots of major changes.

Not sure if you use IntelliJ Idea as your IDE or not, because most Idea users rave about the JetGroovy plugin writtein by the intellij guys. It supports both grails and groovy and for me it's not much different going back and forth between java and groovy.