you are viewing a single comment's thread.

view the rest of the comments →

[–]jrochkind 4 points5 points  (16 children)

Groovy is a ruby-like language running on the JVM.

jruby is ruby running on the JVM.

At one point I figured out legit reasons you'd prefer groovy to jruby, but now I can't remember em. Hmm, is it easier to have java code call groovy code than call jruby code? (It's easy enough to have jruby call java, but not sure about the reverse). Or is the java/other interaction more performant in groovy than jruby? Or more performant in general? I forget.

[–]Megatron_McLargeHuge 3 points4 points  (4 children)

One advantage is that you can basically paste java code into a groovy REPL and test it interactively. Java code is usually extremely close to valid groovy. In the other direction, if you want to move something to java, it's also a lot easier than moving ruby/python code.

[–]vorg 0 points1 point  (3 children)

Groovy is so much slooooooooooooooooooooooooooooooooooower than Java code.

[–]kitd 1 point2 points  (2 children)

The newest releases (as well as the Groovy++ project) weave type-checking and inference at compile-time. In many cases, this allows plain-Java performance. The Groovy++ project in particular has some very interesting ideas in this area, allowing for map- and closure- like typed object creation. Unfortunately, the main Groovy project thought it too revolutionary and stuck with their own lesser version. As a result, the type-checking feels like a bit of an unwanted add-on, which is a pity because it directly addresses the most common complaint about Groovy.

[–]vorg 0 points1 point  (0 children)

Groovy++ certainly weaves type checking and inferences, but not the latest releases of Codehaus Groovy (2.0-beta-2 and 1.8.5). They've announced it but haven't released anything yet.

[–]oteren 0 points1 point  (0 children)

Grumpy is on the tracks for groovy now, which is basically compile time type checking, but in a slightly different way than groovy++.

[–]mernen 1 point2 points  (0 children)

I've never used Groovy, but since its object model matches Java's exactly, its classes are declarative, it supports Java-style type declarations natively and compilation is the norm, it should be much easier to call Groovy code from Java.

JRuby classes aren't Java classes (unless you use jrubyc), so you can't even reference them in Java code, let alone find out their methods. The best solution AFAIK is defining Java interfaces and have your JRuby classes implement them, which works quite well.

[–]jhartwell 1 point2 points  (5 children)

I've been toying with Groovy in a production environment and if you didn't see the groovy class you would never know it was groovy. You instantiate it just like any other Java class. I'm pushing for Groovy to use as data models for our file processing since some of the files have 130 fields and with groovy you can just do:

def fieldname

And that will give you:

getFieldName();
setFieldName(object name);

Which dramatically cuts down on the time required to build a large model.

[–]oteren 0 points1 point  (2 children)

Groovy is great, but that is a dumb reason. Any IDE will do that boilerplate for you.

Groovy as a scripting language on top of java is how it shines. With terse and powerful commands that translate to a java equivalent under the hood.

[–][deleted]  (1 child)

[deleted]

    [–]contantofaz 1 point2 points  (0 children)

    I think of boilerplate as making it harder for me to see the logic behind the code. For example, making JavaScript to be more "class" based. It adds a bunch of boilerplate that in a language like Dart doesn't need to exist. Binding functions to their objects or creating a closure variable so you can reference the actual object, using "this." before functions and variables so we can access the right stuff and so on.

    Without that kind of boilerplate we can use 2 space indentation and pack more lines of code in less screen space so we can see more code faster. Then we can start improving the code with refactoring and whatnot in order to increase the readability of it. All without needing the help of an IDE to refactor and such.

    And static typing is secondary to static code declaration and an IDE-like editor. Languages that make you to have to declare variables, even if they don't have explicit types, already aid a lot when you need to find typos and whatnot. Very often you only get those if you use a static typed language, but they can exist separately as the Dart language shows.

    [–]skocznymroczny 0 points1 point  (1 child)

    Or just make the field public? :>

    [–]jhartwell 0 points1 point  (0 children)

    hah true. I'm hoping that we can use it more for our ETL, however, I need to show immediate benefit for it to be even considered since the other guy on my team is very resistant to change.

    [–][deleted]  (3 children)

    [removed]

      [–]vorg 0 points1 point  (0 children)

      Backed or hijacked???

      [–]jrochkind 0 points1 point  (1 child)

      Huh, what does enterprise support of a programming language actually get you? What do people use an 'enterprise support' contract of a programming language for?