Groovy on Grails: Rapid Development in an Enterprise Environment

Discuss the feature articles on the LDS Tech Home Page.
User avatar
Posts: 490
Joined: Wed Jul 18, 2007 3:38 pm
Location: Salt Lake City, Utah

Groovy on Grails: Rapid Development in an Enterprise Environment

Postby McDanielCA » Wed Mar 11, 2009 10:38 am

Groovy on Grails: Rapid Development in an Enterprise Environment was originally posted on the main page of LDS Tech. It was written by Spencer Uresk.


For the last few years, Ruby on Rails has been one of the most talked-about Web application development frameworks. The popularity Rails has enjoyed isn’t without merit—the “coding by convention” idea it helped make popular was beneficial to Web development in many ways.

Coding (or configuration) by convention allows you to concentrate more on what your application is supposed to do rather than how to get it configured properly, which makes development easier and allows you to be more productive. In my own experience, developing an application and getting it into production with Rails was faster than anything I’d used before.

My colleagues and I were interested in Rails and invested time in learning it and using it, but weren’t thrilled at having to learn an entirely new language and deployment platform. Not being able to take advantage of the multitude of quality Java libraries we were familiar with. How could we get the same development experience, while still using proven Java libraries and existing Java skills?

Enter Groovy on Grails. Grails is a Rails-like (in fact, it was called “Groovy on Rails” until mid-2006) Web application development framework that adopts the same coding-by-convention style employed by Rails, but runs on the Java Virtual Machine and is built using many proven Java libraries and frameworks.

Groovy is a dynamic, object-oriented language. Groovy tends to be easier for someone with Java development skills to understand (and, in fact, virtually all Java code is also valid Groovy code). Since it compiles into Java bytecode, it can easily reference any existing Java code.

This high level of interoperability with Java code allows Grails to make use of existing frameworks. Many of the technologies that make up the LDS Java Stack are also at the core of Grails. (The core of the LDS Java Stack is the Spring Framework, which is also the core of Grails.) Other frameworks that overlap include Hibernate (the Stack uses Hibernate’s JPA implementation), Acegi Security, and Quartz (for job scheduling).

In addition to familiar, proven frameworks, Grails approaches Rails in terms of development speed and ease-of-use. You can generate CRUD (Create-Read-Update-Delete) pages using simple commands, plug-ins are generally easy to install and configure, and the Groovy programming language is both powerful and easy to use.

Grails doesn’t require special deployment considerations—it can generate a WAR (Web ARchive) that will run on any standard servlet container. This makes it easier to deploy in environments where infrastructure and training are already in place for deploying applications onto servers like Tomcat, Weblogic, or WebSphere.

For these reasons, Grails is certainly worth looking into for both Java developers looking for Rails-like productivity, as well as developers who would like to (or need to) work in a Java environment, but do not want to go through the daunting task of properly configuring a Java Web application. Grails is free to use and is released under the Apache License 2.0.

We do not currently use Grails for any projects in ICS, the Java developers in ICS have been looking into it on our own and feel that Grails offers interesting possibilities.

Spencer Uresk is an engineer for the Church.

New Member
Posts: 3
Joined: Fri Mar 02, 2007 10:50 pm

While your experimenting, check out Clojure

Postby ensign_avenger-p40 » Wed Mar 11, 2009 3:56 pm

While your experimenting with JVM languages/frameworks, check out Clojure- it is a dialect of Lisp implemented in the JVM, allowing you to call your Java libraries!

There is also JRuby- the JVM implementation of Ruby. I hear good things aboutSEAM framework, as well-

I think it is very interesting, and exciting, to see how the various languages and frameworks work with each other.

User avatar
Senior Member
Posts: 3241
Joined: Tue Jan 23, 2007 9:56 pm
Location: Utah

Postby mkmurray » Wed Mar 11, 2009 9:34 pm

In the .NET world, there is a project called MonoRail that is supposed to be moving .NET in this direction. However, I think Microsoft is taking it a step further by creating the DLR, built on top of the CLR, in order to bring dynamic language and static language interoperability to .NET. They have a 1.0 version of IronPython and an alpha version of IronRuby. From what I read, Microsoft would love to bring the Rails framework along into the .NET world, but is focusing on making a true, unchanged, and performant implementation of Ruby first.

I also wonder if the new ASP.NET MVC Framework (version 1.0 launch expected any day now) could be made to have a Rails-like framework around it that is convention based.
Many questions are already answered on the LDSTech wiki. Check it out!

New Member
Posts: 2
Joined: Wed Apr 23, 2008 12:12 pm

Postby ascotan-p40 » Fri May 29, 2009 9:19 am

Ruby, python, and groovy are all really quite similiar. If you know one of these languages it should take you all of a week to be comfortable programming in the other.

There are a few gotchas however with groovy.

The biggest thing that you need to be careful of is that groovy ignores alot of error handling. Java will choke on anything unhandled, groovy is the polar opposite in that errors go unhandled or things are cast to null.

def x = [1,2,3]
for (index in 0..3){
println "index ${index}: " + x[index]

will give you the result:

index 0: 1
index 1: 2
index 2: 3
index 3: null

Now in python, ruby or java will throw an error if you try to access an index of a list/array/vector beyond the limits of it's capacity. Groovy will just return null.

The big "WIN" in using groovy over something like ruby or python (with their powerful web frameworks django/rails) is that you can leverage the JDBC and other java frameworks and classes that you already have.

You do have to be careful when writing groovy code however.

A LAMP stack almost always makes sense for low cost (and scalable: [url]’s-largest-websites-are-running-on/[/url]) web development where the P in LAMP = {php, perl, python, (ruby)}. However if your using enterprise java, grails is a nice parallel.

Return to “LDSTech Featured Article Discussions”

Who is online

Users browsing this forum: No registered users and 1 guest