• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What does Groovy/Grails offer?

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've recently delved into java web development. When I was researching popular java web frameworks, grails was often mentioned. I want to wade through the hype, and find out what groovy/grails truly has to offer. I'm specifically interested in:

  • How is grails different from "traditional" java frameworks i.e. Struts2, Stripes, etc?
  • How does grails compare (is similar/different from) to Rails, Django, Pylons?
  • What are groovy/grails weaknesses i.e. Rails/Django fit a particular sweet-spot?
  • How difficult is groovy to pick, especially for someone with knowledge of java and python/ruby?


  • Thanks.
     
    author
    Posts: 77
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Great questions. Here's my attempt at some answers:

    1. Unlike most other Java web frameworks, Grails addresses the full application. If you write an app in Struts2, Stripes, JSF, etc. you still need something else to handle the "back end"; Spring/Hibernate, EJB, etc. Grails uses Spring and Hibernate but builds it in so that all the layers of the application are handled cohesively. Another, and probably more important, difference is convention over configuration. (Note "over" not "instead of") Many basic decisions are made by following simple and sensible conventions. No XML configuration files required. You can configure to hearts content if you want/need to, but in many/most cases you don't need to. This combined with features like GORM dynamic persistence methods (get(), save(), findAllByPropertyName(propertyVal), etc.), custom tags that are so easy they should be illegal, convention based Codecs, URL mapping, and more, make Grails a very productive and enjoyable way to build web applications.

    2. I haven't used Rails or Django, but from what I've heard there are several similarities in philosophy (Convention over configuration, dynamic language, persistence).

    3. There is another thread on this forum that addresses this question pretty thoroughly: https://coderanch.com/t/470335/Groovy/Grails-weak-points

    4. If you have some experience with Java, Groovy will be easy to pick up. If you also have experience with Ruby and Python, then it'll be even easier. Many of the things you like from Ruby or Python and wished were in Java, are likely in Groovy. Groovy basically brings things like closures, metaprogramming and dynamic typing to Java.

    In short, if you are planning on doing web development on the JVM, you owe it to yourself to at least take a look at Grails.

    Have fun,
    Dave

     
    Dan King
    Ranch Hand
    Posts: 84
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks for the insightful answers. However, I do have a few follow-up questions:

  • Can grails integrate with and leverage pre-existing java code such as web services?
  • Since grails addresses the full application can one still leverage the benefits of grails if it is used only in the presentation tier in conjunction with a pre-existing java setup?
  • What is fact and fiction when it comes to groovy/grails performance? I've read in a few places that the performance is "considerably" slower than java.
  •  
    Ranch Hand
    Posts: 15304
    6
    Mac OS X IntelliJ IDE Chrome
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Dan King wrote:What is fact and fiction when it comes to groovy/grails performance? I've read in a few places that the performance is "considerably" slower than java.



    Groovy is slower than Java because of all the reflection that has to happen. As VM reflection improves, so will groovy performance. Groovy also does a fair bit of caching to help boost performance. But it will never be as fast as pure Java. That said, in most cases, the speed at which Groovy code can execute is the least of your performance concerns. Database, network, bandwidth, and all sorts of other things will most likely be the cause first.
     
    Dave Klein
    author
    Posts: 77
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    I think Gregg answered the performance question quite nicely, but I'll take a crack at the other two.

    You can consume web services, RESTful, SOAP, or other, in a Grails application. I would normally put this type of code in a Service class that can then be injected into any of our controllers or domain objects, etc. Grails can also act as a WS server either by coding it from scratch (which is easy with REST) or by using one of several available plugins (XFire, Axis, CXF, DWR).

    You can use Grails for front-end only, though, more acurately, it would be front / middle. In other words you could use Grails views and controllers and have the controllers access services which can call your external web services. You could leave Grails services out of the picture if you wanted to, but I find them very helpful for that sort of thing.

    Hope that helps,
    Dave
     
    Dan King
    Ranch Hand
    Posts: 84
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    You've sold me on Groovy/Grails, with that said - I have just a few more questions (I promise):

  • I know I can get up to speed on Groovy/Grails fast with "Grails: A Quick-Start Guide" but do you think I'll need or should look into any supplemental books?
  • Do you know if/when "Grails: A Quick-Start Guide" is going to be available in kindle or ePub format?


  • Thanks for the insights; I appreciate it.

    Best,
    Dan
     
    Dave Klein
    author
    Posts: 77
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Grails: A Quick-Start Guide is currently available in kindle and epub formats (along with PDF) at pragprog.com. One price gets you any or all formats as well as updates.

    If you are going to continue working with Grails, I would recommend getting Grails in Action and/or Definitive Guide to Grails. For more in-depth Groovy info, I highly recommend Programming Groovy by Venkat Subramaniam, which you can also get in kindle format at pragprog.com.

    I hope you enjoy the adventure and if you get stuck you can post questions here.

    Dave
     
    Dan King
    Ranch Hand
    Posts: 84
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Thanks for the heads-up on the Kindle/ePub versions - I checked Amazon and B&N, neither had it - and the other Groovy/Grails books.

    Best,
    Dan
     
    Dave Klein
    author
    Posts: 77
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    You're welcome. All the Pragmatic Programmer's ebooks are only available from http://pragprog.com. One thing to note is that if you buy one of their paper books from Amazon.com or from a bookstore, etc. you can register it at and still get the combo discount on the electronic version. I recently did that with several books in my library.

    Dave
     
    reply
      Bookmark Topic Watch Topic
    • New Topic