Ruby vs. Groovy: your perspective

Hello,
I realise this is a very hot topic… and people have strong feelings
about either language. I am not trying to trolling.

Still I’ve heard a bit about Groovy and it kind of seems like the Java
answer to Ruby (even the names are kind of similar). So I was
wondering if that kind of “first citizen” status will eventually make
it take over Ruby as a dynamic language (assuming that indeed that the
Groovy language offers everything Ruby does).

I checked online, but websites are either very old, or too “official”.
So I wanted to ask my fellow Ruby programmers, who probably share
similar preferences to mine.

Note: I am not sending this to the Groovy list or the Java list. I
don’t program in either, I program in Ruby, and what I am looking for
is not an “official” intro to Groovy, just some opinions from Ruby
users. Many things are about personal preference, not checking boxes
on a list. (for that there’s wikipedia) :slight_smile:

So thoughts? Does Groovy (the language) have everything to offer that
Ruby does? And the fact that it was designed to be used on the JVM
from they one gives it an advantage (I know I can keep use Ruby, but a
strong community means more libraries out there, more books, and in
general more help).

Fire away. :slight_smile:

Diego V.

Use whatever language makes you happy (i do). There is plenty of room
among
programmers to accommodate new languages and they tend to bounce idea
off
each other which keeps development from getting stale, languages don’t
just
die because something new came out, for example you can still find
contingents of pascal programmers around. One issue with groovy is (at
the
moment) shackled to JVM which has both it’s pros and cons. Overall
groovy
looks like an interesting language but for the moment i don’t have a
compelling reason to use it.

On Mon, Apr 13, 2009 at 7:35 AM, Diego V.
[email protected] wrote:

Hello,
I realise this is a very hot topic… and people have strong feelings
about either language. I am not trying to trolling.

Still I’ve heard a bit about Groovy and it kind of seems like the Java
answer to Ruby (even the names are kind of similar). So I was
wondering if that kind of “first citizen” status will eventually make
it take over Ruby as a dynamic language (assuming that indeed that the
Groovy language offers everything Ruby does).

I am not really familiar with Groovy, but I’m somewhat surprised you
didn’t mention JRuby here.
It runs on the JVM, lets you access the wealth of the Java libraries,
and is fully compatible with Ruby 1.8.6.
It is also targeting Ruby 1.9 features over time.

So I’m not sure why I’d use something “like Ruby” if I could just use
Ruby.

-greg

Use whatever language makes you happy (i do).

Well, that was the plan. And currently Ruby seems more elegant. But is
this true? And is it more powerful? And it’s easier to use? I dunno. I
guess I could pick a book and start reading it. But currently I don’t
have much interest in learning Groovy if in the end it ends up exactly
like Ruby.

So I was hoping someone who has tried both could tell me a little bit
more on their opinion.

On Apr 13, 2009, at 9:05 AM, [email protected] wrote:

And currently Ruby seems more elegant. But is this true?

This is pretty much personal opinion. Which ever one feels better to
you is better.

And is it more powerful?

There’s no such thing. Both languages are Turing Complete
(Turing completeness - Wikipedia
). Thus, they are literally capable of the same things.

And it’s easier to use?

Again, that’s pretty much personal preference. What’s easy for me may
not be easy for you.

James Edward G. II

I am not really familiar with Groovy, but I’m somewhat surprised you
didn’t mention JRuby here.

You are right… and I think I’ve not explained myself very well. I
was interested to hear people’s opinion about Groovy to get an idea if
I may want to invest some time in learning it or not.

To this end, I currently have two main concerns:
1- A language I enjoy using. Ruby is such a language so far (apart
from the speed). On the other hand is Groovy? Are the two really on
feature parity? What are their advantages over each other? I could
find very little recent stuff on Groovy, and as you put it << I’m not
sure why I’d use something “like Ruby” if I could just use Ruby >>. So
what is the feeling of the Rubyist that have already looked closely at
Groovy?

2- A language that will be around for a (relatively) long time, and
with a strong community support. I mean, I know Ruby per se would not
disappear if people stopped using it, but still, with little support
there are less libraries, and the technological world is a moving
target, so a language with no development would slowly become less and
less useful.

So I am sorry I confused everybody by mixing the two points. I was
trying to address both points in the opening post, but I didn’t
distinguished the two questions very well. I hope things are more
clear now. :slight_smile:

Diego

On Apr 13, 2009, at 9:20 AM, [email protected] wrote:

I was interested to hear people’s opinion about Groovy to get an
idea if
I may want to invest some time in learning it or not.

Well, learning new languages is a good thing. I’ve enjoyed most of
what I’ve worked with, even if they didn’t replace Ruby for me.

1- A language I enjoy using. Ruby is such a language so far (apart
from the speed).

I’ve been pretty impressed with 1.9’s speed. Time to make the switch!

2- A language that will be around for a (relatively) long time, and
with a strong community support.

While some languages do die, I think it’s a pretty rare thing. Most
languages are still around in some form and generally have a community
supporting them.

James Edward G. II

On Mon, Apr 13, 2009 at 4:43 PM, James G. [email protected]
wrote:

(Turing completeness - Wikipedia). Thus, they are literally
capable of the same things.
Of course, but I would like to give a broader interpretation to
“performance”.
There are (at least) two interpretations of “powerful” that make a
difference here.

The first is “how fast I can achieve my goal”, and I believe Ruby is
difficult to beat in this domain.
This only might not be true in the case of the need of some very
specific java libraries to be reused. Groovy might have an adavantage
here, which otoh you might be able to overcome with JRuby :). (1)

If, and it is a big IF, you mean execution speed with powerful, Groovy
is probably faster, but yet there is JRuby and unless heading into the
direction of some very specific code, worrying about speed now is a
bad decision.

Really I did not like Groovy but that is why I am on this list :).
Check it out by all means if you are not happy with Ruby, but its is
quite clear, that on this list most folks will concur with your first
impressions ;).

(1) Avoid continuations

And it’s easier to use?
Actually maybe not, Ruby has some subtleties which Groovy might not
have, but to learn them is very rewarding and relatively easy because
of excellent material available (c.f. Pickaxe book
Pragmatic Bookshelf: By Developers, For Developers of which
you find an older version for Ruby1.8 online which I would recommend
by all means ) and also thanks to some very helpful folks on this
list.

HTH
Robert


Si tu veux construire un bateau …
Ne rassemble pas des hommes pour aller chercher du bois, préparer des
outils, répartir les tâches, alléger le travail… mais enseigne aux
gens la nostalgie de l’infini de la mer.

If you want to build a ship, don’t herd people together to collect
wood and don’t assign them tasks and work, but rather teach them to
long for the endless immensity of the sea.

On 13 Apr 2009, at 12:35, Diego V. wrote:

So thoughts? Does Groovy (the language) have everything to offer that
Ruby does? And the fact that it was designed to be used on the JVM
from they one gives it an advantage (I know I can keep use Ruby, but a
strong community means more libraries out there, more books, and in
general more help).

I followed Groovy development for a while (between 2004-2006) and
liked what I saw, but ultimately gave up on developing for the JVM and
lost interest. Were it to break out of that particular ghetto I think
it could gain in popularity, although from what I recall it’s similar
enough to Ruby in many respects that it might be difficult to
differentiate itself.

Ellie

Eleanor McHugh
Games With Brains
http://slides.games-with-brains.net

raise ArgumentError unless @reality.responds_to? :reason

On Tue, Apr 14, 2009 at 12:29 AM, Eleanor McHugh
[email protected] wrote:

I followed Groovy development for a while (between 2004-2006) and liked what
I saw, but ultimately gave up on developing for the JVM and lost interest.
Were it to break out of that particular ghetto I think it could gain in
popularity, although from what I recall it’s similar enough to Ruby in many
respects that it might be difficult to differentiate itself.

Clojure pushes the jvm as a strength [Clojure - Rationale].
It’s certainly nice to have all those libraries for free and a
well-optimised vm, though I got a trifle disillusioned when I wrote an
app in it and discovered that yes, swing does suck. (Some day I’ll
work up the energy to scrap the UI and rewrite it in QtJambi)

martin

Eleanor McHugh wrote:

I followed Groovy development for a while (between 2004-2006) and liked
what I saw, but ultimately gave up on developing for the JVM and lost
interest. Were it to break out of that particular ghetto I think it
could gain in popularity, although from what I recall it’s similar
enough to Ruby in many respects that it might be difficult to
differentiate itself.

I don’t know if I’d consider the JVM a ghetto :slight_smile: At any rate, I think
there’s practically no chance of Groovy ever living anywhere but the
JVM, since they’re tightly intertwined with both Java the platform and
Java the languages.

  • Charlie

On 13 Apr 2009, at 22:14, Charles Oliver N. wrote:

Eleanor McHugh wrote:

I followed Groovy development for a while (between 2004-2006) and
liked what I saw, but ultimately gave up on developing for the JVM
and lost interest. Were it to break out of that particular ghetto I
think it could gain in popularity, although from what I recall it’s
similar enough to Ruby in many respects that it might be difficult
to differentiate itself.

I don’t know if I’d consider the JVM a ghetto :slight_smile:

Well I’ll concede that the JVM does have a few things going for it,
but I never was entirely comfortable with having my code tightly
coupled to it. The Groovy guys have a different outlook and good luck
to them for that - if we all thought alike we’d never get anywhere lol

Ellie

Eleanor McHugh
Games With Brains
http://slides.games-with-brains.net

raise ArgumentError unless @reality.responds_to? :reason

Charles Oliver N. wrote:

Eleanor McHugh wrote:

I followed Groovy development for a while (between 2004-2006) and
liked what I saw, but ultimately gave up on developing for the JVM and
lost interest. Were it to break out of that particular ghetto I think
it could gain in popularity, although from what I recall it’s similar
enough to Ruby in many respects that it might be difficult to
differentiate itself.

I don’t know if I’d consider the JVM a ghetto :slight_smile:

In some ways MRI is more of a “ghetto” in that if you ever end up using
a native-code library you may find it hard to run you code on multiple
platforms, whereas if you use JRuby with Java libs you have far more
portability.

As it stands, it’s a fair bet that Ruby + Java gives you more libraries
than Ruby + C.

That’s not to claim there are no downsides to running on the JVM, just
that the Java platform seems to have been tagged with a very outdated
image, and people are doing themselves and others a real disservice to
so blithely dismiss it.


James B.

www.jamesbritt.com - Playing with Better Toys
www.ruby-doc.org - Ruby Help & Documentation
www.rubystuff.com - The Ruby Store for Ruby Stuff

Eleanor McHugh wrote:

Well I’ll concede that the JVM does have a few things going for it,
but I never was entirely comfortable with having my code tightly
coupled to it.

When you’re writing in Ruby, your programs are tightly coupled to the
Ruby interpreter. Why is that better than having a program coupled to
the JVM?

On Mon, Apr 13, 2009 at 5:35 AM, Diego V.
[email protected]wrote:

Still I’ve heard a bit about Groovy and it kind of seems like the Java
answer to Ruby (even the names are kind of similar). So I was
wondering if that kind of “first citizen” status will eventually make
it take over Ruby as a dynamic language (assuming that indeed that the
Groovy language offers everything Ruby does).

One of the most powerful Ruby idioms I know of requires features Groovy
doesn’t have. I’m talking about creating a small declarative “DSL” you
call
from a class body to metaprogram methods, such as with ActiveRecord
associations, e.g.:

class Foo < ActiveRecord::Base
has_many :bars
has_many :bazzes, :through => :quuxes, :order => “created_at DESC”
end

This allows for instances of Foo to potentially respond to many
different
methods based on the association names (e.g. you can call afoo.bars to
get a
collection of associated bars)

Groovy does not allow code in class bodies (at least last I checked),
and I
believe Grails tries to work around this with static properties, which
can’t
provide the full expressive power of a DSL.

I’ve heard generally bad things about Groovy’s approach to metaclasses
and
metaprogramming in general, but as I haven’t used Groovy I can’t really
comment in that regard.

On Tue, 14 Apr 2009 17:11:58 +0900
Albert S. [email protected] wrote:

Eleanor McHugh wrote:

Well I’ll concede that the JVM does have a few things going for it,
but I never was entirely comfortable with having my code tightly
coupled to it.

When you’re writing in Ruby, your programs are tightly coupled to the
Ruby interpreter. Why is that better than having a program coupled to
the JVM?

Ruby is open-source. Ruby runs everywhere.

Regards,

Michael

On Tue, 14 Apr 2009 16:34:45 +0900
James B. [email protected] wrote:

In some ways MRI is more of a “ghetto” in that if you ever end up
using a native-code library you may find it hard to run you code on
multiple platforms, whereas if you use JRuby with Java libs you have
far more portability.

Portability is very subjective :slight_smile:
For many years, Java was only supported on a handful of platforms,
others like for example FreeBSD weren’t (I’m talking about Sun’s Java
here).
I still can’t run Java and depending applications like OpenOffice on a
specific operating system, until OpenJDK becomes ready.

Portability for me means, that I have full access to the C/C++ code, and
it compiles easily on every platform. Welcome to Ruby :slight_smile:

As it stands, it’s a fair bet that Ruby + Java gives you more
libraries than Ruby + C.

Sure. But does it give us more quality? My own (limited) experience
with Java was that it’s very hard to find a usable, bug-free HTML parser
in Java (TagSoup without bugs), which on the other hand was very easy in
Ruby (Hpricot).

Regards,

Michael

On 14 Apr 2009, at 08:34, James B. wrote:

In some ways MRI is more of a “ghetto” in that if you ever end up
using a native-code library you may find it hard to run you code on
multiple platforms, whereas if you use JRuby with Java libs you have
far more portability.

All platforms are ghettos by their very nature. In the case of Groovy,
it’s a language closely coupled to a particular platform - the JDK -
which is out of the control of its creators and therefore breaking
free from that ghetto could prove too difficult to be worth the
investment. That’s a pity for Groovy because it’s a language that’s
fun to play with and that freed of the JDK constraint might not look
out of place rubbing shoulders with Ruby and Python.

As it stands, it’s a fair bet that Ruby + Java gives you more
libraries than Ruby + C.

That’s not to claim there are no downsides to running on the JVM,
just that the Java platform seems to have been tagged with a very
outdated image, and people are doing themselves and others a real
disservice to so blithely dismiss it.

I’ve been coding for almost thirty years, and for ten of those I
followed the JVM closely enough to have been a reasonable JASM coder.
So if I’m blithe in my tone, that’s not without having formed an
opinion through experience and come to the conclusion that I want and
need
my code to live in a world larger than that circumscribed by the
JDK.

In Ruby that’s easy as Charlie and his confederates have built me a
first-class tool to use in JRuby with very few restrictions on the
kind of Ruby code it’ll support, whilst MRI still gives me support on
a host of other platforms thanks to its ANSI-C implementation. For the
Groovy folks that could well be impossible.

Ellie

Eleanor McHugh
Games With Brains
http://slides.games-with-brains.net

raise ArgumentError unless @reality.responds_to? :reason

Michael N. wrote:

Portability is very subjective :slight_smile:
For many years, Java was only supported on a handful of platforms,
others like for example FreeBSD weren’t (I’m talking about Sun’s Java
here).
I still can’t run Java and depending applications like OpenOffice on a
specific operating system, until OpenJDK becomes ready.

Portability for me means, that I have full access to the C/C++ code, and
it compiles easily on every platform. Welcome to Ruby :slight_smile:

I’m also running the BSD port of OpenJDK on Mac right now.

As it stands, it’s a fair bet that Ruby + Java gives you more
libraries than Ruby + C.

Sure. But does it give us more quality? My own (limited) experience
with Java was that it’s very hard to find a usable, bug-free HTML parser
in Java (TagSoup without bugs), which on the other hand was very easy in
Ruby (Hpricot).

http://java-source.net/open-source/html-parsers

No promises, of course, but there’s a lot more to pick from.

  • Charlie

On Tue, Apr 14, 2009 at 10:23 AM, Michael N. [email protected]
wrote:

the JVM?

Ruby is open-source. Ruby runs everywhere.
Well so is the JVM, open source and run everywhere :). But to add to
your answer, it is better to be coupled to Ruby than to the JVM,
because you are one abstraction higher and although JRuby is a great
thing to use you do not depend on the JVM, which is good. If use JRuby
because you depend on Java features you do not loose anything, because
you are bound anyway. If you use JRuby for other reasons you will not
be bound to JRuby and can use any other rubyspec compliant
implementation :).
Robert

Si tu veux construire un bateau …
Ne rassemble pas des hommes pour aller chercher du bois, préparer des
outils, répartir les tâches, alléger le travail… mais enseigne aux
gens la nostalgie de l’infini de la mer.

If you want to build a ship, don’t herd people together to collect
wood and don’t assign them tasks and work, but rather teach them to
long for the endless immensity of the sea.