Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the Grails advantages over other Java Web Frameworks?

I've worked with JSF, Spring MVC and Struts and I think I got a good level on these frameworks. Recently I heard that many good developers I worked with are learning Grails and using it in their projects.

What are the practical advantages of Grails over other frameworks? Is worth to learn it besides I know other frameworks? What is all the buzz around Grails, is it only because of Groovy?

NOTE: I did research in SO and the only related question I found was this and Grails is not mentioned

like image 913
victor hugo Avatar asked May 22 '09 04:05

victor hugo


People also ask

Is Grails a good framework?

Grails is an extremely popular open source web application framework powered by the Groovy programming language and based on the Java Virtual Machine (JVM). The software community has given a big thumbs-up to Grails due to its smart features.

What is the use of Grails framework?

Grails provides a development environment that includes a web server to get developers started right away. All required libraries are part of the Grails distribution, and Grails prepares the Java web environment for deployment automatically.

What is better Grails or spring?

In the question“What are the best web frameworks to create a web REST API?” Spring-boot is ranked 2nd while Grails is ranked 29th. The most important reason people chose Spring-boot is: Boot is just a thin configuration layer over Spring Framework, as such it inherits all the strengths of Spring.


1 Answers

Grails is, like you say, built off Groovy which gives the immediate benefit of being more productive. The Groovy syntax is much terser than Java, it's much easier to do things in one line of Groovy code that would take you several in Java.

Grails specifically provides you with a number of advantages over other web frameworks (I can only talk for Struts 1.x, 2.x and SpringMVC however) - Grails is actually built on top of SpringMVC by the way and you can integrate other components using Spring.

  • Database Migrations and Versioning - no more application out of sync with database schema syndrome. Most Java web apps suffer from this.

  • Artefacts - which make creating new controllers and components easier. No more create a controller, configure it and stuff it into the right place in your web app. doh! Scaffolding also provides you with all some initial components to allow you to start building your pages and customising

  • Simpler validation (def simpler than Struts 1.x), e.g. username(size:6..10, blank:false) specifies two validation rules for a username field to be of a specific length and non blank. It's a bit harder in the other Java web app frameworks.

  • Built in Webflow (via Spring webflow) which makes creating complex workflows much simpler. Struts 2 can support Webflow, but via a plugin which is a little odd if I rememeber. Spring can too.

  • Interceptors - SpringMVC also has these.

  • Flash scope, see http://grails.org/doc/docs/1.1/ref/Controllers/flash.html

  • Better data binding - Struts 2 is pretty good, much better than Struts 1. SpringMVC is also good.

There's a few more, check out the documentation for more details: http://grails.org/doc/1.1.1/

like image 168
Jon Avatar answered Sep 30 '22 14:09

Jon