Friday, May 8, 2009

Groovy is the new Perl / Java / ...

The past weeks I've been doing some programming with Groovy and Grails, a relatively new programming language/web application framework, and I'm starting to like it a lot. It's not perfect, but I think it can beats it competitors, with one hand behind its back.

In the past I've done a lot of Java. It's a very good language, but it has some downsides:
  • It's not suitable for scripting. Its syntax is simply too verbose, it's strictly Object-Oriented, it has to be compiled, etc.
  • It doesn't have a single best web application framework. There are so many of those in the Java space that is practically impossible to keep up with them, all have pros and cons. If you pick one now you can be sure that it's hopelessly outdated in 3 years. It's getting to be a big mess.
  • It doesn't have a single best Rapid Application Development environment. This is related to the previous point - in my view programming is all about productivity and maintainability. Maintainability of Java programs is mostly good, but productivity is mostly not so hot. The JSF framework is very promising in this area, but because of all the fragmentation and FUD it's gaining traction slowly.
On the other hand Java has one big plus: It's powerful. With all it's standard libraries, myriads of Open Source frameworks and support from all the big vendors (except Microsoft) it's everywhere.

So now we have Groovy/Grails. Let me show you how it beats all its competitors and predecessors:
  • Java. This one's easy. Instead of fighting Java it simply stands on its shoulders. Groovy can do everything Java can do because it's Java-based. You can use all those libraries, if you want all the frameworks too (even though Grails is the way to go). And Groovy is good for scripting. Matched with Grails you get a scripting language with an excellent ORM and dynamically generated web interface thrown in for free.
  • C#.Net. Groovy and Grails are Open Source. Besides C#.Net is mostly a Java wannabe, so if our new favorite can beat Java it can surely beat .Net.
  • Ruby on Rails. Conceptually and feature-wise Ruby/RoR and Groovy/Grails are closely matched. However the fact that Groovy is Java-based is such a strong advantage that it makes Ruby/RoR irrelevant. Grails also offers better run-time performance.
  • Delphi. Even though Delphi has fallen out of fashion it is probably still one of the best RAD environments ever. It is only recently that JSF and Swing-based tools come close in terms of productivity. Grails takes this RAD ability one step further in RoR fashion: an Object-Relational Mapper that is 100% to the point, dynamically generated web interfaces and the ability to fall back to custom coding wherever you want, with full Groovy and Java power available.
  • PHP. PHP is all about hacking together a web interface quickly, without thinking about maintainability, re-using code etc. If requirements change a lot PHP code will quickly become spaghetti. Security is weak. Let's face it: 1995 called and wants its language back.
  • Perl. I've used Perl a lot in the past - it used to be the king of scripting languages. Unfortunately in 2000 the Perl developers lost touch with the real world and started to develop the perfect scripting language, Perl 6. They're still at it, apparently. Meanwhile Perl 5 has become hopelessly outdated. It lacks elegant OO and a good web framework, to name only a few downsides. Its syntax is so compact (there is some truth in the joke that every randomly typed string of characters is a valid Perl program) that maintainability suffers. Groovy has none of these downsides, and - as far as I can see - doesn't miss any of Perl's major features.
Nothing's perfect. So what are some of the things that could push this winner to even greater heights?
  • Documentation. Groovy/Grails have a lot of power, but some of it is very hard to find. There isn't a single place where it's all described in full. Often you have to make do with some basic examples and a lot of Googling.
  • IDE support. It's clear that one of the main concepts behind Grails has been to make an IDE unnecessary to a large extent. Don't Repeat Yourself and all that. You can get by with just a text editor. Also, Eclipse and Netbeans have basic support. Still, it would be nice to have better debugging and real-time syntax checking/refactoring. Here Java still has a clear advantage.
  • Spring-based. I was a bit disappointed when I found out that Grails is Spring-based, because it adds an extra layer of complexity that is (in my view) often not really needed. In practice Spring stays out of the way when you work with Grails so this isn't really a major issue. It does add to the very very long stack traces that you get when something goes wrong though..
  • Grails views are not component-based. Some effective tag library magic is used to give a first impression that is JSF-like, but the full power of JSF with its drop-in visual component libraries, data binding and IDE drag&drop visual design are missing. It's likely that JSF support will be added to a future version of Grails. I'm not yet sure if that will be an improvement (worst-case it will take away a lot of Grail's simplicity and push it back into the shark-invested waters that make up Java's web application framework landscape).
Anyway. If you do a lot of web programming and /or scripting, then you really owe it to yourself to take Groovy and Grails for a spin.


  1. You should use Moose/Mouse for OO Perl programming.

  2. And Catalyst for Perl web development. Your view of Perl 5 is seriously outdated.

  3. [Perl] lacks elegant OO and a good web framework, to name only a few downsides.Have you seen Moose and Catalyst? It's hardly fair to criticise Perl like that when, apparently, you stopped keeping up to date with the language five years ago.

  4. This comment has been removed by a blog administrator.

  5. Steven,

    Before you talk about Perl "features" and have's/have not, you should really learn more about the current world of Perl.

    I would recommend these two blogs:


    I think you'll find that you have inaccurately described the current Perl world.

    Best regards,

  6. It doesn't have a single best web application framework.There are so many different ways to develop web application, that there should be more than one way to do it. A language that has only one official way to do things will be outdated very quickly.

  7. In addition to the other posters' comments, your exploration of C#.Net seems to be based entirely on logical reasoning and not on any sort of experience. This is not the most convincing way to make your case for Groovy.

  8. This comment has been removed by a blog administrator.

  9. Real languages not only have an official web framework, but also have an official text encoding, like ASCII. All hail ARC!

  10. I hear your loss of confidence in Perl. I think the timelines originally banded about for Perl 6 have proven almost comically inaccurate, and, as a fan of both marketing and of Perl, I've found the situation for both Perl 5 and 6 highly disconcerting.

    But consider Mozilla. By 2000 a lot of people had lost confidence in the project. I was a volunteer within the Mozilla community during the days when volunteers half-jokingly referred to themselves as "doomed". But the project kept going and produced Firefox, which I think was/is a reasonable outcome.

    I've been watching Perl 6 and related projects since day one, patiently reading literally tens of thousands of emails, and I think Perl 6.0.0 and Parrot 2.0 will soon (less than 2 years) ship and shake things up, to the surprise of many, in a manner analogous to Firefox 1.0.

  11. Basically a poorly researched and presented article. "It doesn't have a single best web application framework. It doesn't have a single best Rapid Application Development environment." What do those have to do with Java (or any language) being a good/bad language? And of course the obviously outdated view on Perl and all.

  12. "It lacks elegant OO and a good web framework, to name only a few downsides."

    Err, no? It just happens to have what a lot of people consider to be the best framework for Object Oriented development, Moose.

    You should try and do some homework if being credible has any value to you.