Groovy and Grails: Ten Pleasant Surprises

May 15th, 2007

After meeting Graeme Rocher at JavaOne, I decided it was time to give Groovy and Grails a second look. Here are the ten items that jumped out at me, as a Java and Ruby developer learning about Groovy and Grails:

  1. While new languages often introduce gratuitous syntactic differences, Groovy’s differences are often appealing. I think I could come to like the syntax for case equality (===), hashes ([x:'y']), and open ranges (1.<10) better than their Ruby counterparts.
  2. I have often wished for the safe dereference operator (e.g. org.person?.name) when writing Ruby code. I am sure people will use this to paper over Demeter violations, but it is nevertheless worth having.
  3. Grails defaults to an in-memory HSQLDB database for development. This is even easier than Rails, setup-wise.
  4. Grails follows Rails’ lead in providing a flash scope, and goes a step further in implementing a chain scope. I will be adding this feature to my Rails projects.
  5. Grails has a built-in dynamic scaffold, more like Streamlined than a static scaffold.
  6. Grails generalizes the notion of a builder library with reusable support for building arbitrary nested structures.
  7. Grails’ model saving support (save/validate/discard) is more complex than Rails’. On first glance, I feared this was unnecessary complication, but actually it is quite nice. The common case is simple, and parallel to Rails. The other cases are there if you need them.
  8. As applications become more complex, Grails makes nice use of Spring’s autowiring to inject supporting classes. (I find that excessive autowiring obfuscates relationships, but the Grails examples I have seen so far look just right.)
  9. The Groovy MetaClass (and its use in Grails) is very powerful. As Graeme points out, the MetaClass brings Groovy much closer to having the whole language there, all the time. Groovy still does not have open classes, but open invocation is a workable alternative for many use cases.
  10. The Definitive Guide to Grails is a very good book. If you are coming from a Java or Ruby background, this book is a perfect jump start for both Groovy and Grails.

Stu Halloway

Tags:

Groovy Things To Do With Groovy

May 8th, 2007

Guillaume Laforge demonstrates some of the hottest features of the Groovy programming language and covers new features in the upcoming 1.1 release (like annotations), and talk about using Groovy to create cool mashups, among other things.

Tags:

Intro to Groovy & Grails (Scott Davis, Video, Part 1)

, May 8th, 2007

Tags: ,

Intro to Groovy & Grails (Scott Davis, Video, Part 2)

, May 8th, 2007

Tags: ,

Groovy and Grails On A Roll (Charles Ditzel)

May 8th, 2007

There were 600 developers sitting in on the Groovy session this morning.  I missed it.  I came in late - saw how huge the line was and saw that the room was already almost filled and I abandoned all hope.  Afterwards I met with Guillaume LaForge (Groovy) and Graeme Rocher (Grails). It is clear that these symbiotic communities are growing quickly. Leveraging the the  large advantage of being a Java-based framework with culturally and syntactic closeness to Java there is an increasing number of Java developers that are finding it to be closer to their developer culture than alternatives (like Ruby). Incidentally, Grails 0.5 is now out.  New features included are : Custom URL mappings DSL, command objects/form validation, list and map support in GORM, support for composition in domain class (Hibernate “components”),  Base64 codec,  dependency resolution with Ivy, Project metadata and versioning support, script event hooks, new Artifact API available to plugins and much more.

Charles Ditzel

Tags:

Cool New Features In Grails 0.5 (Jeff Brown)

May 1st, 2007

Grails 0.5 was released today and this release is one of the most exciting releases yet. This release has closed the gap on a number of key features that needed to be knocked out before the coming 1.0 release. Some of the new features will be more appealing to some projects and other features more appealing to other pojects. For me some of the coolest new features added in 0.5 are Command Objects, List and Map Support in GORM and Custom URL Mappings. Hundres of JIRA issues have been addressed in this release and significant performance enhancements have been made. The development team got a whole lot done during this iteration. See the release notes for a more complete list of new features.

With the recent release of the first beta of Groovy 1.1, things continue to heat up in the Groovy and Grails communities.

This year I have been speaking at Java User Groups, internal training events and on the No Fluff Just Stuff Tour about Groovy and Grails and I am finding that folks in the Java community are really excited about both Groovy and Grails and the possibilities that these technologies bring to their projects. After a bit of time that really seemed kind of dull for the JVM, Groovy and Grails are making it all fun again and at the same time adding a lot of value to the enterprise by increasing productivity and expanding the possibilities. For example, defining a DSL using Antlr or similar technologies may not have been a realistic possibility for many applications but dynamic technologies like Groovy make things like that not only possible but simple to build. There are many many examples just like that which represent ways Groovy can help developers get their jobs done faster and more simply. Frankly, I don’t think Grails would be anywhere near as compelling as it is if it weren’t for all of the coolness made possible by Groovy. Grails has taken the possibilities that Groovy provides and leveraged them all over the framework to provide simple concise techniques for web application developers to use to build powerful web applications very quickly.

Grails has earned a lot of respect in the community by getting very far along in a short amount of time. While Grails applications are already being deployed in production environments, both private and public facing sites, the coming 1.0 release is going to push Grails right out there to the front of the pack. This is exciting stuff!

More to come… :)

Jeff Brown

Tags:

Grails Gathers Steam, Heads for 1.0

, May 1st, 2007

In the past few years, web frameworks have increasingly been focused on productivity. Ruby on Rails is seen by many as the poster-child for rapid web development, which has put a lot of pressure on traditional frameworks. In the Java marketplace, a number of frameworks are responding to that call by aiming for increased productivity, rapid development, and support for scripting languages. From Grails to Stripes, RIFE to Trails, Tapestry 5.X and Phobos, there are a lot of people looking for new ways to make Java web development a productive, rapid environment for building web applications that scale.

Grails, a Rails-style web framework using Groovy on the Java platform, has been getting a lot of attention lately, with a rapidly growing community and increasing production use for major corporations including Tropicana and Pepsico. Grails is often compared to Ruby on Rails, which is both an opportunity and a challenge, as people are attracted to the power of a Rails-like framework on a familiar platform, but may move on to Rails itself. A recent set of comparisons imply that Grails has the edge on performance for now, but that new releases of Ruby promise better performance across the board, and that may change.

Although there has been some discussion about support for Ruby within Grails, it doesn’t currently seem likely. If, instead of integrating Ruby with Grails, you’d like to integrate parts of Grails with your other applications, it is apparently possible to use the Grails object/relational mapper, GORM, outside of a Grails context, such as in a Java desktop application. All of the major IDEs are showing signs of increased support for Groovy and Grails. There’s been some discussion of IDE support in Netbeans, as well as discussion of improvements for GroovyJ in IDEA. Eclipse has the beginnings of a Grails plugin and new releases of the Groovy/Eclipse plugin and Edward Povazan working on improved code completion support with Big Sky Technology.

Grails recently released version 0.5, with improved performance, custom URLs, enhancements to GORM and more. Next on the roadmap is 0.6, with a 1.0 release late in the year. InfoQ spoke with Graeme Rocher, a co-founder and the project lead for Grails about its current success and the future.

When asked about the recent surge in attention for Grails, Graeme responded:

Well, Java developers all over are being made aware that configuration is no longer a necessary activity and Grails is one of the frameworks leading this surge. However, in comparison to other frameworks, Grails has a really strong message around re-using your existing Java knowledge, infrastructure, and code. Grails is as elegant as Rails, but as flexible as Spring MVC or Seam. It really does provide the best of both worlds. As to the uptake, that has really been lead by our community and world of mouth. We spent over a year putting together a 0.1 release; if it had been mediocre no one would have paid any attention. As it is, we have many happy users who are spreading the word and increasing Grails’ mindshare.

When comparing Grails to other frameworks for building web applications in Java:

Well, it really embraces DRY and convention-over-configuration. You really have pretty much zero configuration when developing a Grails application. However, you get all of this AND tight Java integration with existing APIs, libraries and frameworks like the Java Enterprise stack, Spring, Hibernate & SiteMesh.

In addition it has a number of key selling points. Including an extensible plug-in system, a domain-driven ORM layer built on Hibernate, and a powerful view technology with Groovy Server Pages (GSP).

On convincing someone to try Grails for the first time:

Developers don’t really need a lot of convincing, it is more management that is the struggle. However, if I do want to convince people to use Grails, I just do a quick 5 minute demo and they’re sold.

As to where Grails goes next, for v1.0 and therafter, Graeme Rocher said:

We’re really focusing on improving the developer experience and getting out 1.0 by autumn time. We have only a few “big” jobs left and then it is just incremental improvements to reach the finishing line. Some things that we have left to do are for example JSP tag library support in GSP, possible support for JPA as a plug-in, and improvements to our unit testing infrastructure.

Overall though we are mainly focused on getting 1.0 out the door after that we’ll look at leveraging the infrastructure we have in place and writing many plug-ins for Grails to continue to improve the developer experience. For example I really want to get round to writing a Groovy compiler for GWT that hooks into Grails as a plug-in, which should be fun.

If you’d like to learn more about Grails, you can continue to read about Grails at InfoQ, or take a look at Grails website, read Getting Started with Grails or the Definitive Guide to Grails.

Geoffrey Wiseman, InfoQ

Tags: ,