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 Virasoro

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 9:35 PM, Diego Virasoro <Diego.Virasoro@gmail.com>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 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 Virasoro

--
The UNIX system has a command, nice ... in order to be nice to the other
users. Nobody ever uses it." - Andrew S. Tanenbaum

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

···

On Mon, Apr 13, 2009 at 7:35 AM, Diego Virasoro <Diego.Virasoro@gmail.com> 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).

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 Mon, Apr 13, 2009 at 5:35 AM, Diego Virasoro <Diego.Virasoro@gmail.com>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).

--
Tony Arcieri

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

···

On 13 Apr 2009, at 12:35, Diego Virasoro 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).

----
raise ArgumentError unless @reality.responds_to? :reason

"Diego Virasoro" <Diego.Virasoro@gmail.com> schrieb im Newsbeitrag news:5bd5ae80-a5bd-4a95-815e-988de2e068bd@y7g2000yqa.googlegroups.com...

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).

Depends on your colleagues.
If you are in a Java environment and want to implement some scripting, then it's probably better to start with Groovy.
If you are in an environment where not much people know _and_ _like_ Java, start with Ruby.

For the long term, try to aquire both.

IMHO, Java is the language of choice for (portable) GUI-Apps if you don't have the need for hardware-or OS-near programming.
(There are GUI-Libs for Ruby too, however, currently no IDE provides possibilities for Ruby as some do for Java.)

Ruby is wonderful for scripting, with a broad range of capabilities.
You could use very advanced features, but you're able to start at a very low level. Which is important when colleagues which are specialized on another area should be able to modify your scripts.

Michael B.

I don't think anyone has already mentioned this, but Yehuda Katz
posted this a few days ago it contrasts one aspect of Ruby vs. Groovy.

···

On Mon, Apr 13, 2009 at 7:35 AM, Diego Virasoro<Diego.Virasoro@gmail.com> 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 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.

--
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

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.

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

Clojure pushes the jvm as a strength [http://clojure.org/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

···

On Tue, Apr 14, 2009 at 12:29 AM, Eleanor McHugh <eleanor@games-with-brains.com> 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.

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

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.

Thanks that's exactly the kind of tidbits I was looking for.

Diego

Michael Bruschkewitz said:

IMHO, Java is the language of choice for (portable) GUI-Apps if you
don't have the need for hardware-or OS-near programming. (There are
GUI-Libs for Ruby too, however, currently no IDE provides possibilities
for Ruby as some do for Java.)

Better still, use JRuby. All the advantages of Java (when you need it)
and all the bnefits of Ruby when you don't. (You can package and deploy
with rawr.)

Ruby is wonderful for scripting, with a broad range of capabilities. You
could use very advanced features, but you're able to start at a very low
level. Which is important when colleagues which are specialized on
another area should be able to modify your scripts.

As a Java dude, I got into Ruby precisely for its ease of use for
scripting. JRuby is the icing on the cake.

···

--
Best,
Marc

"Change requires small steps."

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 (http://en.wikipedia.org/wiki/Turing_complete\). 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 Gray II

···

On Apr 13, 2009, at 9:05 AM, Diego.Virasoro@gmail.com 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 Gray II

···

On Apr 13, 2009, at 9:20 AM, Diego.Virasoro@gmail.com 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. 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

···

On 13 Apr 2009, at 22:14, Charles Oliver Nutter 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:

----
raise ArgumentError unless @reality.responds_to? :reason

Charles Oliver Nutter 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 Britt

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

"marc" <gmane@auxbuss.com> schrieb im Newsbeitrag news:h0akoq$eti$2@ger.gmane.org...

Michael Bruschkewitz said:

IMHO, Java is the language of choice for (portable) GUI-Apps if you
don't have the need for hardware-or OS-near programming. (There are
GUI-Libs for Ruby too, however, currently no IDE provides possibilities
for Ruby as some do for Java.)

Better still, use JRuby. All the advantages of Java (when you need it)
and all the bnefits of Ruby when you don't. (You can package and deploy
with rawr.)

That's what I discussed yesterday w/ Logan, rawr-Maintainer.
I did JRuby into Java integration in my last project.
But my colleagues already know Ruby.

My argument was:
If you're in an environment which is familiar to Java but not to Ruby, I would prefer Groovy.

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
(http://en.wikipedia.org/wiki/Turing_complete\). 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

···

On Mon, Apr 13, 2009 at 4:43 PM, James Gray <james@grayproductions.net> wrote:

On Apr 13, 2009, at 9:05 AM, Diego.Virasoro@gmail.com wrote:

--
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.

--
Antoine de Saint-Exupéry

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?

···

--
Posted via http://www.ruby-forum.com/\.