What are the Grails advantages over other Java Web Frameworks?

后端 未结 3 1401
既然无缘
既然无缘 2021-02-03 10:59

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

相关标签:
3条回答
  • 2021-02-03 11:09

    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/

    0 讨论(0)
  • 2021-02-03 11:21

    BTW, Grails is not considered as a Java Framework, its for Groovy. Groovy has the capability to work with Java seamlessly, but thats the different story.

    Yes, its about Groovy, and like Java its awesomely good. Groovy follows the notion "Code less, do more", whereas Java is something like "Code more, do more". No offense to Java folks, I am one of you.

    You might want to read these:

    • Success Stories of Grails
    • Whats New in Groovy 1.6
    0 讨论(0)
  • 2021-02-03 11:24

    Grails adds Groovy goodness to existing Java frameworks and provides the tooling to use it easily:

    • Grails (web part) = Groovyfied Spring MVC (like @Jon points out)
    • GORM = Groovyfied Hibernate
    • GroovyTestCase = Groovyfied JUnit TestCase

    @Jon already mentioned some concrete practical advantages. I would like to point out two more fundamental concepts in the Grails approach:

    1. Convention over configuration. If you adhere to the conventions set out by Grails (which are very sensible btw) you can become productive very quickly.
    2. Don't Repeat Yourself (DRY) Grails enables you to write DRY code and in itself is a good example of how to be DRY. If you have any existing Java code reusing it in Grails should be no problem.

    So,

    Is it worth learning?

    I think for you yes. Since you already know Java and some of the available frameworks (especially Spring MVC) the learning curve should not be steep at all.

    What is all the buzz around Grails, is it only because of Groovy?

    The buzz could be explained because Grails demonstrates that Groovy can be leveraged to create a very usable "product".

    0 讨论(0)
提交回复
热议问题