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:

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. Required fields are marked *

Related Blog Posts
An Exploration in Rust: Musings From a Java/C++ Developer
Why Rust? It’s fast (runtime performance) It’s small (binary size) It’s safe (no memory leaks) It’s modern (build system, language features, etc) When Is It Worth It? Embedded systems (where it is implied that interpreted […]
Getting Started with CSS Container Queries
For as long as I’ve been working full-time on the front-end, I’ve heard about the promise of container queries and their potential to solve the majority of our responsive web design needs. And, for as […]
Simple improvements to making decisions in teams
Software development teams need to make a lot of decisions. Functional requirements, non-functional requirements, user experience, API contracts, tech stack, architecture, database schemas, cloud providers, deployment strategy, test strategy, security, and the list goes on. […]
JavaScript Bundle Optimization – Polyfills
If you are lucky enough to only support a small subset of browsers (for example, you are targeting a controlled set of users), feel free to move along. However, if your website is open to […]