Python vs Groovy vs Ruby? (based on criteria listed in question)

Question:

Considering the criteria listed below, which of Python, Groovy or Ruby would you use?

  • Criteria (Importance out of 10, 10 being most important)
  • Richness of API/libraries available (eg. maths, plotting, networking) (9)
  • Ability to embed in desktop (java/c++) applications (8)
  • Ease of deployment (8)
  • Ability to interface with DLLs/Shared Libraries (7)
  • Ability to generate GUIs (7)
  • Community/User support (6)
  • Portability (6)
  • Database manipulation (3)
  • Language/Semantics (2)
Asked By: Prembo

||

Answers:

I know it’s not on your list, but at least look at perl.

  • Richness of Api/Libraries to sink a ship.
  • Runs on more systems than most people realise exists.
  • Works well with Binary libraries.
  • Has a huge community.
  • Portability, See above.
  • Database manipulation: more ways to do it. ( Pick your favorite module )
  • And one of the most expressive/terse languages around.
Answered By: Kent Fredric

I think it’s going to be difficult to get an objective comparison. I personally prefer Python. To address one of your criteria, Python was designed from the start to be an embeddable language. It has a very rich C API, and the interpreter is modularized to make it easy to call from C. If Java is your host environment, you should look at Jython, an implementation of Python inside the Java environment (VM and libs).

Answered By: Ned Batchelder

This sort of adding-up-scores-by-features is not a good way to choose a programming language. You’d be better off choosing whichever you know the best. If you don’t know any of them, try them out for a little while. If you have a really specific project in mind, then maybe some programming languages would be better, but if you just have general preferences you will never come to a consensus.

That said, Python is pretty flexible, it’s the most popular on your list so the easiest to solve whatever sorts of problems you have by searching, so I’d recommend Python.

Answered By: lacker

Just to muddy the waters…

Groovy give you access to Java. Java has an extremely rich set of APIs/Libraries, applications, etc.

Groovy is embeddable, although easiest in Java.

DLLs/Libraries (if you’re talking about non-Groovy/Java) may be somewhat problematic, although there are ways and some APIs to help.

I’ve done some Python programming, but being more familiar with Java, Groovy comes a lot easier to me.

Answered By: Ken Gentle

Python has all nine criteria. It scores a 56.

I’m sure Ruby has everything Python has. It seems to have fewer libraries. So it scores a 51.

I don’t know if Groovy has every feature.

Since Python is 56 and Ruby is a 51, Python just barely edges out Ruby.

However, I think this kind of decision can still boil down to some subjective issues outside these nine criteria.

Answered By: S.Lott

Perl? Yikes.

As someone has observed Perl is like a big explosion in a punctuation factory. It’s terseness is not an advantage if the resultant code is not self documenting.

Have used Groovy for some utility tasks, easy to get going. Full access to Java libraries, plus some cool addtions to it, like listing the files in a directory using a closure:

// process all files printing out full name (. and .. auto excluded)

new File(basedir).eachFile{ f->

    if (f.isFile()) println f.canonicalPath
}
Answered By: Chris Brooks

try Groovy .. it has all features that you need there. You can use existing java lib without any modification on its classes.
basically .. groovy is java++, it is more dynamic and fun to learn (just like ruby)

I dont like ruby or python syntax so I will put them behind. Groovy is just like C/C++ syntax so I like him lol 🙂

Answered By: adwin

Groovy? I’m just picking it up; try this (inside the groovyconsole):

File.metaClass.invokeMethod = { String name, args ->
    System.out.print ("Call to $name intercepted...");
    File.metaClass.getMetaMethod(name, args).invoke(delegate, args);
}

new File("c:/temp").eachFile{
    if (it.isFile()) println it.canonicalPath
}

The first code is AOP. All calls to any method of File object will be intercepted. No additional tools required. This is executed against existing Java class dynamically.

In the second block, you remove the ‘f’ closure parameter. Being just one parameter, it defaults to the built in “it” variable available to the closure context.

Here is what you get:

“Call to isFile intercepted…C:tempimg.jpg”

etc.

Answered By: Florin

From your critera, I’d pick JRuby:

  • Richness of API/libraries available (eg. maths, plotting, networking) (9)

Everything the JVM has access to, which is a lot

  • Ability to embed in desktop (java/c++) applications (8)

Excellent Monkeybars framework, which lets you design a swing GUI in your GUI designer, and then wire it up using clean ruby code

  • Ease of deployment (8)

Rawr can package your app as an executable jar

  • Ability to interface with DLLs/Shared Libraries (7)

Java shared libraries easily, C ones via jna + libffi

  • Ability to generate GUIs (7)

Swing just works. Not sure how easy it is to use QtJambi, but it’s definitely possible.

  • Community/User support (6)

Lots. Ruby has an excellent community.

  • Portability (6)

Everywhere the JVM works

  • Database manipulation (3)

All the ruby database libraries and all the java ones

  • Language/Semantics (2)

Here’s where ruby takes the definite lead over groovy and python. The language has had some really beautiful design decisions taken early on, which shows up in the consistency and power of the standard library. Blocks, in particular, make it a joy to use.

Answered By: Martin DeMello

Having worked with all 3 of them, this is what I can say:

  • Python

    • has very mature libraries
    • libraries are documented
    • documentation can be accessed from your debugger/shell at runtime through the docstrings
    • you can develop code without an IDE
  • Ruby

    • has some great libraries ( even though some are badly documented )
    • Ruby’s instrospection mechanisms are great. They make writing code pretty easy ( even if documentation is not available )
    • you can develop code without an IDE
  • Groovy

    • you can benefit from everything Java has to offer
    • syntax is somewhat inspired from Ruby
    • it’s hard to write code without an IDE. You have no way to debug stuff from your console ( this is something you can easily do in Python/Ruby ) and the available Groovy plugins have a lot of catching up to do. I wrote some apps using Groovy and as they get bigger I regret not going with Ruby/Python ( debugging would have been WAY more easier ). If you’ll only develop from an IDE, Groovy’s a cool language.
Answered By: Geo
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.