To Groovy Or JRuby

This is something that I have been thinking about, to Groovy or (J)Ruby. All of us, developers, would like to learn a scripting language. And when I say learn, I mean to be proficient in it.

Currently, in the Java world, we have two main scripting languages, Groovy and JRuby. The questions that we ask ourself is what should we learn. First, let me explain what it means to learn a new language. Learning the syntax is usually the simple task, but it is important to understand that it does not end there. In order to really know how to use the language, we need to know all the different popular frameworks that comes with it, idioms on how to use it, and so on. If we take the Java world as an example, it is not enough to learn Java as a language, developers need to be familiar with Java design patterns, core Java concepts and design patterns, JEE, Spring and many others…

So, to the question presented in this title, what should a developer learn? Should it be Groovy or JRuby? Both have a very active community and very interesting frameworks that come with them - Grails in Groovy and Ruby on Rails in JRuby/ruby.

The question is an open question to the community, and I would love to hear your views on it. The main thing that I currently think about is this: with Groovy, moving from Java to Groovy seems to feel more natural, Groovy grew out of Java, which gives it a big boost in terms of learning curve (Grails feels like that as well). On the other hand, ruby is really picking up, and if someone chooses to learn ruby (and ruby on rails), it can be used both on the Java world using JRuby, and in future possible projects that will use only ruby, basically making anyone learning ruby more sexy in terms of future jobs.

I don’t know the answer, maybe you can help?

19 Responses to “To Groovy Or JRuby”

  1. Jason Says:

    No question: Groovy.

    This isn’t even a debate. Groovy has native JVM integration, native library support and all the syntactical sugar of Ruby. Why bother with JRuby? I can’t find a compelling reason (and I know Ruby like the back of my hand!).

    Groovy, and by extension Grails, are awesome technologies that every Java dev should take a close look at.

    And, with the new Groovy 1.1 annotation support, you can even write Seam, Hibernate, Spring and other frameworks natively in Groovy!! Exciting times!

  2. Cay Horstmann Says:

    I would like to say Groovy for the same reasons that Jason cites, but I have found my forays into Groovy land less than happy. The documentation is a mess. The source code is a mess. There is no publicly viewable language reference, so you never quite know what is right and wrong. The books describe outdated versions of the language. Grails is indeed impressive, but I am not confident that it is built upon a solid foundation.

  3. Charles Oliver Nutter Says:

    I would recommend you try them both for the sorts of tasks and problems you need to address. Both languages have similar approaches to some problems and very different approaches to others. You’ll do best to choose the language that feels right to you and gets the job done in the way that you find most comfortable.

    And keep in mind the intangibles you’ll run into down the road, like performance, community, available libraries and momentum, and presence of published documentation and tutorials. The language you choose should have a good answer for all of these.

    Above all, don’t let anyone make the choice for you. You’re the one that has to live with the decision. And accept that the best answer may be “learn both.”

  4. Anonymous Says:

    how about beanshell. that’s pretty slick too.

  5. Uri Says:

    I think in today’s world, the language is just one facet of the overall development process. Another major facet is the development environment, whether it’s the IDE or the build process. In general, I believe that Groovy is more appealing for java developers for of the reason you already mentioned which is about the easy transition. On the other hand, in my opinion, the future success of Groovy highly depends on its IDE support. From experience this support quick lacks at the moment, mainly in terms of refactoring, development hints (auto-completion), and proper debugger. Just imagine writing java today without refactoring support or auto completion and auto import insertion - unthinkable. Although I don’t have much hands on experience with Ruby, it seems to be better positioned in that matter.

  6. Nicolas Doye Says:

    (Disclaimer: I’ve used Groovy and Grails, but not Ruby, JRuby or Rails).

    I started learning Groovy (and Grails) because I didn’t think JRuby would ever get there (and I didn’t fancy learning Ruby). I was, of course, wrong.

    Groovy has the advantage that is nice and easy for Java developers to use (as it’s so similar). Grails is pretty good, but isn’t as mature as Rails.

    Once JRuby runs all the RoR goodness, it could be the tipping point, and the other wannabe Rails imitators might just fade away. Which would be a shame, as Groovy and Grails really are quite nice and there’s a good community.

  7. Herval Freire Says:

    Groovy is Java only. Ruby is multiplatform (I’m talking JVM, .Net and Ruby on it’s own, here). That alone is reason enough for me to prefer Ruby over Groovy…

  8. Jeff Grimshaw Says:

    One of the benefits of Groovy goes beyond whether it’s the best tool for the job. As a manager the fewer languages I have to maintain, the better. Reason? It gets expensive to hire individuals that know lots of languages. Or it takes time/money to get them up to speed in a new language with a new syntax. Enter Groovy. With a syntax so similar to Java any proficient Java developer can begin working with Groovy quickly. And with Grails I have a web framework that has the same developer productivity as Ruby on Rails. So now I can hire just Java developers (with a little Groovy/Grails training) and cover scripting, web development, rich client applications, enterprise applications and mobile applications. And these applications run on any O.S. that has a JVM. Even Blu-ray high-definition supports Java which opens up another market. Catch the wave!

  9. smudge Says:

    I’m occasionally tempted by JRuby, but then I read something like this and it makes me realize that it’s always gonig to have some ugly compomises that Groovy won’t. I can’t see enough advantages to JRuby over Groovy to counteract that.

  10. Emmanuel Pirsch Says:

    Follow the red rabbit (link) below for my take on the subject… Basically, I like JRuby… But as Charles Nutter said… “don’t let anyone make the choice for you.”

  11. Calvin Yu Says:

    I would say to learn Ruby/JRuby, and the reason has nothing to do with the technical details. You said it yourself, Groovy grew out of Java, so the learning curve is easier. In a way, you can say you learn less by learning Groovy. Ruby, having not grew out of Java, has a different way of doing things, so you do stand to learn more.

    If you’re looking at learning something that will give you a different perspective on programming try Ruby. If you’re looking on something that might nicely compliment your skill set, Groovy might be a better option.

    Calvin

  12. Paul King Says:

    > There is no publicly viewable language reference, so you never quite know what is right and wrong.
    True, but the same applies for all other JVM scripting languages at present.

    > The books describe outdated versions of the language.
    Groovy in Action describes the latest 1.0 (non-beta) release

    > Grails is indeed impressive, but I am not confident that it is built upon a solid foundation.
    It really depends if you think Hibernate and Spring are a good foundation or not.

  13. Andres Almiray Says:

    I’m a Groovy fan but this time I think the soundest counsel comes from Charles Nutter, try them both. If you have acces to the books (Groovy:GINA, Ruby:the pickaxe) then you’ll have an easier and happ experience.

  14. Anonymous Says:

    Javascript. Sun is including it in Java 6.

  15. iznobad Says:

    For me, groovy is more attractive for performance reasons. Both languages seem good, but I’m a speed nut, and simple can’t stand the slow speed of the ruby interpreter.
    Yes, I know there are things in the works to improve ruby speed (compiler and/or specializer), but they’re not here yet
    Jruby is interpreted too, it’s not compiled code.

    Groovy can be compiled and performance is pretty close to java. As far as I can gather it’s like 80% or more of java’s speed when running similar code on the same JVM.

  16. Leonardo Soto Says:

    Jython is a pretty solid scripting language for the JVM too.

  17. David Black Says:

    Groovy every day of the week and twice on Sundays. The fundamental premise of Ruby was flawed i.e. we don’t want to leverage Java, Java has become too bloated. Nonsense of course, Groovy is superior by design because it was conceived correctly - the whole point is that people want to leverage Java. Groovy has everything Ruby has and more but without that fundamental flaw. Now we see JRuby basically admitting the mistake and attempting to graft Ruby onto the JVM and to work with Java. But it can never do so as well as Groovy which started from this premise. JRuby is just a poor Groovy, why bother?

  18. David Black Says:

    And its worth noting that as regards IDE integration the latest stable development builds of the Groovy+Eclipse plugin are now very usable (I know, I’m using it every day) and getting more and more functional very rapidly.

  19. M Easter Says:

    Yes, the best answer may well be “learn both”.

    Yet another answer may be “it doesn’t matter, as long as you learn _one_”.

    It may simply be too early to predict which one will pay dividends, but it is certainly true that a person will benefit their career and passion for software by delving into either Groovy or JRuby. Flip a coin and go for it!

    I am less enthused by the other options, including Jython (sad to say… I love it and Python).

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>