Nov 4, 2010

Why Grails?

I’ve been working with Grails for most of the past year and a half and I think it’s great. In fact, all of my colleagues that have worked with Grails agree and none of us want to go back to plain old Java-based development. When we have a project where we can decide on the technology stack, we choose to use to use Grails whenever we can. The popularity of this technology is really gaining momentum! So what is all the excitement about? It’s about being productive by getting development done quickly and efficiently… and it’s fun too.

I recently worked on a project for a company that was debating about whether or not to use Grails as part of their technology stack. The team was torn and most of the developers were against using technologies new to them and wanted to stick with more a traditional technology stack using Java and Spring. As contractors, we were asked “Why Grails?”.

Well for starters, Grails is built on Spring and Hibernate. In addition, Grails/Groovy integrates easily with code already written in Java, allowing seamless integration with existing Java code. You can even intermix Java and Groovy code in the same file and it will work just fine. This is a huge benefit as you’re learning Groovy, and helps to shorten the learning curve. Once you’re ready to deploy, you build a war file which you can deploy to any web server.

Perhaps the greatest benefit to adopting Grails is that you don’t have to write all of the plumbing/boilerplate code yourself. This makes the team productive much sooner on a project, giving them more time to write the functional code; and ultimately getting development done quicker. Grails uses convention over configuration, and auto-wires everything together for you based on simple naming conventions.

In addition, Grails projects are easier to maintain because of the naming conventions and standard project structure. These conventions make it very easy for a new developer to quickly familiarize themselves with the code and get up to speed on any Grails project. The added benefit to this is that Groovy code is much more concise than Java code, which means there are fewer lines of code; adding to the speed with which a new developer can become productive on the project.

These are the key benefits of using Grails, but I’ve only scratched the surface. Other benefits of using Grails are…

  • Scaffolding – With a couple of simple commands, Grails will generate your views and controllers based on the domain classes you define. This is optional, you can create these on your own if you prefer. This is very helpful when you’re first starting out.
  • Validation – Grails has a bunch of validators out of the box, and makes it easy to write your own custom validation.
  • Testing – Grails provides a testing framework that makes writing unit and integration tests easy.
  • Grails Plugins and Tags – Grails makes it easy to create your own plugins and custom tags. But if you have a need for common functionality in your application, chances are there’s already a Grails plugin or tag already written for it.

Now, back to the project I mentioned above… for this client, we wrote a fully functional piece of software in four months using Groovy/Grails. This was an Agile project, so this four months included the time it took us to flush out the requirements and do the design work, as well as testing and some refactoring. Once the Grails project was completed, we were asked to put together an estimate for rewriting the identical piece of software with Java and Spring. Our estimate for the Java/Spring rewrite was over three months; almost as long as it took us starting from scratch with Grails!! Since we already knew the requirements, functionality and domain intimately; this estimate was purely for development and testing time. As the developers on the project, we knew the estimate would be high; but even we were shocked at how much longer it would take to write this same functionality using Java and Spring.

There are pros and cons for any technology stack that you could choose to use; but in my experience, the benefits of using Grails far outweigh any negatives. Here is a list of sites that are known to be using Grails: http://grails.org/Success%2BStories.

If you are a Java developer and are looking to learn something new, I encourage you to take the time to learn this technology and work to adopt it at your company. Any Java developer can sit down with a Grails book and understand the basics in a few hours. You’ll be amazed at how quickly you can build a fully functional web application with Grails.

About the Author

Object Partners profile.
Leave a Reply

Your email address will not be published.

Related Blog Posts
Natively Compiled Java on Google App Engine
Google App Engine is a platform-as-a-service product that is marketed as a way to get your applications into the cloud without necessarily knowing all of the infrastructure bits and pieces to do so. Google App […]
Building Better Data Visualization Experiences: Part 2 of 2
If you don't have a Ph.D. in data science, the raw data might be difficult to comprehend. This is where data visualization comes in.
Unleashing Feature Flags onto Kafka Consumers
Feature flags are a tool to strategically enable or disable functionality at runtime. They are often used to drive different user experiences but can also be useful in real-time data systems. In this post, we’ll […]
A security model for developers
Software security is more important than ever, but developing secure applications is more confusing than ever. TLS, mTLS, RBAC, SAML, OAUTH, OWASP, GDPR, SASL, RSA, JWT, cookie, attack vector, DDoS, firewall, VPN, security groups, exploit, […]