Your Thoughts on the Groovy Scripting Language? 128
lelitsch asks: "Does anyone have first hand experience with Groovy?
I am just coming off implementing a Plone-based intranet CMS and got hooked on scripting languages and Python all over again. Since most of my projects in the near future are going to be in Java or have large Java components, I was wondering if it's time to trade Jython--which seems to be falling further behind the Python release cycle--for something else. Groovy sounds like a fun thing to look at, but it seems a bit new and thin. Also, what are other languages (JRuby and Rhino, for example) you have used to script in Java?"
Comment removed (Score:5, Insightful)
Re:Jython and CPython (Score:3, Informative)
Jpype -- how active, how serious? (Score:2)
The sense I get is that there is a world of people reconciled to Java, and a world of people who have issues with it and want something else -- see RMS recent and recurring remarks about how Java hurts FOSS everywhere, everytime (or is it that other dude who has issues with Java numeric processing?).
I don't have to get in on the pissing context of t'is, t'ain't regarding whether to go with the Jav
Re:Jpype -- how active, how serious? (Score:1)
Not that many people need to interface Java with CPython. It's sufficiently functional for those who need it.
I just don't quite get what your main point of the post is.
>> see RMS recent and recurring remarks about how Java hurts FOSS everywhere, everytime (or is it that other dude who has issues with Java numeric processing?).
Sure. Soon as you post a link. I don't follow every remark RM
Re:Jpype -- how active, how serious? (Score:2)
Matlab is actually pretty good about hosting ActiveX widgets if you observe some not-insurmountable restrictions. If I go about supplying ActiveX widgets to people happy to use Matlab under Windows, life is good, but for long term, this is do
Re:Jython and CPython (Score:4, Informative)
The problem with groovy is that it is young. It is just starting into the release candidate phase. Some people have written articles bashing groovy for missing expected features like good parsing error feedback. These articles are unfair since they are evaluating a product that is unfinished. I do not recommend groovy for any production purpose yet, it's simply not ready.
Re:Jython and CPython (Score:1)
None of those limitations you state are real.
1.) Jython compiles to Java byte code just like Groovy (jythonc is the compiler included with Jython).
2.) Jython supplies it's own class library based on CPython that can be used from Java (after you compile to byte code since they are written in Python).
Jython may lag behind CPython but it is great port of a battle tested language and I doubt it lacks any features c
Have you tried ColdFusion? (Score:1, Funny)
Ruby (Score:2, Informative)
I'm giving a presentation on using Ruby for scriptable
I haven't played much with Groovy, but I like the idea of Ruby in that I can write scripts that will run standalone, in
Re:Ruby (Score:2)
Well, it depends on what you are using it for.
For example, I had a boss want to add scripting support to a C# windows app. With Ruby for .NET, we could do something like:
So, while the above example may be a lame one, the point is that because you have full access to the .NET objects, you can deploy a scriptable app, without your users having to write C# code and compi
Re:Ruby (Score:2)
Compiling on the fly is not exactly a problem with CodeDom APIs available for all MS .NET languages, and I found JScript.NET to be a very good scripting language, as well as being familiar to many people out there (everyone who worked with DHTML).
Re:Ruby (Score:1)
Re:Ruby (Score:2)
Re:Ruby (Score:2)
Re:Ruby (Score:2)
Bean Shell Script (Score:5, Informative)
If you want to do embedded scripting in Java, I suggest Bean Shell [beanshell.org] instead. As a library, Bean Shell is about 280K, Groovy is about 1.7M. And Bean Shell has been around for a lot longer.
I'd like to see Sun add closures and better support for lists/maps in Java itself (e.g. a map function). I'm hoping that pressure from Ruby will make the language grow. C# already made them change their mind about Generics.
Java had generics before C# (Score:3, Informative)
Java was a little slower actually getting it in, but that's because they had a lot of legacy code to consider and how to make generics that would be useful even with older libraries. In no way was Java actually pressured to include Generics just becas
Re:Bean Shell Script (Score:5, Informative)
Java doesn't need a map function (Score:2)
In Perl:
map { $_ * 2 } @arr;
In Java:
for( Integer key : arr ) { key *=2; }
Now exactly, what would be the benefit of having a map function in Java, aside from obfuscating things? Everything in Java is already a pointer so operations inside your for() loop are already altering the objects in the array or collection.
Re:Java doesn't need a map function (Score:1, Informative)
you wrote:
> Perl: map { $_ * 2 } @arr;
> Java: for( Integer key : arr ) { key *=2; }
This is clearly not what 'map' is intended for.
map works entirely in 'block context', it
takes a list (array) as a whole, does something
an returns another list (array). You wouldn't
modify the original array in a map block.
This is what you might 'map' use for:
Regar
Re:Java doesn't need a map function (Score:1, Informative)
That Java code doesn't do anything. The variable named 'key' starts by holding a reference to an Integer object; then you (implicitly) call Integer.intValue() and multiply the result by 2; and then call Integer.valueOf(that) to get a reference to a new Integer object; and that object reference is stored back in the variable 'key', replacing 'key''s original object reference.
Variables in Java do store references (pointers) to
Re:Java doesn't need a map function (Score:2)
for( Integer key : arr ) { key *=2; }
I beliefe you mean something like this:
for (int i = 0; i < arr.length; i++) {
arr[i] *= 2;
}
I would be surprised if your code example works (as intended) as it has to unbox the Integer, then multiply it with 2, and then descide if the array was made from ints or Integers and again descide if it boxes or unboxes them again. Oki, I fire up the compiler and check it: it does not work neither w
Re:Java doesn't need a map function (Score:2)
I tried this with int and Integer as type for the variable arr, in all except Java 5 (.5) using an Integer would have given compiler errors.
As several posters pointed out: the original code generates interims helper objects, which are modified, the original array is never changed.
angel'o'sphere
Re:Java doesn't need a map function (Score:2)
Your perl example didn't modify @arr; in fact it did nothing at all. Try something like:
Where map really starts to shine in applications like the Schwartzian Transform [wikipedia.org].Re:Bean Shell Script (Score:1)
Re:Bean Shell Script (Score:2)
Groovy does not claim to be a finished product. Does anyone suggest otherwise? Why do so many people need to make long winded disections of exactly how it is unfinished? This critique provides a set of likes and dislikes. Unfortuantely, the section of dislikes is an example of the kind of unhelpful impatience that many people seem to be hurling at groovy now. Every single one of the critici
Re:Bean Shell Script (Score:2)
Re:Bean Shell Script (Score:2)
Because the product has been around long enough to be a lot less unfinished.
What are you basing that on? You own opinion of how long it "should" take to create a new language? Please provide your evidence/reasoning to justify this. I recall using mozilla a couple years in and it sucked pretty bad. Now firefox is awesome. I recall the same chorus of "why are you taking so long, why do you have so many bugs?". In fact, I think that kind of impatience only happens to projects that will be great. It's only if p
Re:Bean Shell Script (Score:2)
C# already made them change their mind about Generics.
C# has generics since C# 2.0 (which is officially released since 3 monthes)
Java has generics since Java 1.5 (no called Java 5) whichis officially released since 16 monthes (or something).
Inofficially Java has generic extensions since 1.4 (as an add on to teh compiler) since 3 years, or more.
When in C# 1.0 the talks about gnerics and how they will work started, Java had generics some days alter. The very first generics for Java wehe from the year
Re:Bean Shell Script (Score:1)
Re:Bean Shell Script (Score:2)
But is Beanshell able to implement interfaces, subclass normal and abstract classes and give them back to Java as normal classes with methods that can be called in the Java way? I don't think so.
Yes, it is!
angel'o'sphere
Re:Bean Shell Script (Score:2)
Flavor of the Month (Score:1, Troll)
Why? (Score:5, Insightful)
Stop the groovy naming (Score:2, Insightful)
Re:Stop the groovy naming (Score:5, Funny)
Re:Stop the groovy naming (Score:2)
Re:Stop the groovy naming (Score:2)
fact clarification (Score:1, Informative)
Re:Stop the groovy naming (Score:2, Informative)
There are exceptions,
Nothing beats Lua (Score:5, Informative)
There is Java/Lua integration in the form of JLua [hetland.org] and LuaJava [keplerproject.org]. Possibly other tools as well.
Re:Nothing beats Lua (Score:4, Informative)
http://lua-users.org/ [lua-users.org] is your friend.
Re:Nothing beats Lua (Score:2)
The one downside to Lua is that it doesn't have real regular expressions. Of course that only matters for some applications.
Re:Nothing beats Lua (Score:1)
Re:Nothing beats Lua (Score:2)
It depends on what you consider "close". If you list the notation that Lua has, it appears to have most of the constructs that true regular expression packages have. However, it lacks alternation and closure, which are two of the three defining properties of regular expressions. It even appears to have these, but if you look carefully, it turns out that it has them only for singletons, not for arbitrary subexpressions.
I don't doubt that Lua could easily include a real regular expression package, but it
Re:Nothing beats Lua (Score:2)
The one downside to Lua is that it doesn't have real regular expressions. Of course that only matters for some applications.
Hm, AFAIK lua has a VERY GOD expresion mathcing system. the WoW client is scripte with Lua and all string matching there are more or less "one liners", not true regexps it seems, but very easy to sue, nevertheless (I did never dig ito it, can only tell from sources I modifeid).
angel'o'sphere
Re:Nothing beats Lua (Score:4, Interesting)
*nods*
I never use anything else any more --- it's small (compiling into an 200kB binary with no dependencies on my platform), it's fast (faster than Python!), it's simple (you can easily understand the entire language), it's elegant (closures, coroutines, a superb callout interface...), and it's flexible (there's enough functionality under the surface that you can, e.g., rewrite the OO system to better suit your needs). It's also BSD licensed, which means that there are no legal hurdles to using it in your project; if you play games, you've probably already used Lua without realising it.
I will admit to not being overly enamoured with its syntax --- it uses Pascalish if...then...end style rather than C's if () {} style --- but I can easily live with that.
Testimonial: I wrote a gaim plugin not long ago for the Citadel BBS. It was easier to bolt the Lua engine onto gaim and write the logic in gaim rather than try and figure out how to do it in gaim. Lua's coroutines support allowed me to turn gaim's callback-based API into a callout-based structure, which in turn allowed me to invert all my nasty complex state machines, which made the whole thing an order of magnitude less complex. Good stuff.
uhhh (Score:1)
If You Enjoy Scheme.. (Score:3, Informative)
Re:If You Enjoy Scheme.. (Score:1, Informative)
Re:If You Enjoy Scheme.. (Score:2)
People who like general-purpose languages (Score:1, Flamebait)
Re:People who like general-purpose languages (Score:3, Funny)
Even other scripting languages like Perl, [debian.org] Lua, [debian.org] or Python [debian.org] would clearly be foolish choices as well.
Seriously, Ruby's a great, well thought-out language, but if you listened to the hype you'd think that there couldn't possibly be anything better for any task at all. The fanboyism that's grown up around the language is starting to become really irritating.
Re:People who like general-purpose languages (Score:2)
Re:People who like general-purpose languages (Score:2)
Once again, I've got nothing against Ruby as a language, the passing experience I've had with it showed it to be a fairly elegant, easy-to-use language. That doesn't make it the all-powerful duct tape of the universe that s
Re:People who like general-purpose languages (Score:3, Interesting)
I can.
Mind you, I'm do a lot of Ruby coding, and I love the language. However:
Re:People who like general-purpose languages (Score:2)
It's a good language, but it certainly has its weaknesses, not the least of which are performance or the lack of a good UI toolkit.
Re:People who like general-purpose languages (Score:2)
My choice of word emphasis was misleading. I wasn't implying that you though Ruby was fast; I was emphasizing that Ruby isn't fast. It looked, in my post, like I was contradicting you, when I wasn't. Sorry. :-)
I like the Qt bindings. They're pretty easy to use, and it provides a look-and-feel that integrates we
Groovy Falls Behind True Scripting Languages (Score:1, Interesting)
Am I not getting something? (Score:1)
If I want to script from a Java program, I call ascript using Runtime.getRuntime().exec(cmd). The de-facto scripting languages are Bourne shell or Perl. Most scripters can read/maintain these. Only very reluctantly I will write scripts in any other language than these. As a very strict rule, anything I cannot do in Bourne, I do in Perl.
What makes Java very unsuitable for scripting is the absence of a Posix package. Setting own
Re:Am I not getting something? (Score:2)
Issue here is that "scripting" is used very liberally and is misleading.
Here, it is used to label every language that has anything that looks like dynamic typing, which means that Python or Ruby get labelled as "Scripting Language" while they're much closer to general purpose programming languages that allow rapid application developments and have script-type glueability.
While Python or Ruby can be used to (and often are) glue several components, they do shine on larger applications, they're not limited t
I am looking for a Matlab replacement (Score:2)
I use Sleep (Score:1)
Re:I use Sleep (Score:1)
Hecl (Score:3, Informative)
it is perhaps less general-purpose than the poster might want, but I have different design considerations in mind:
Small, flexible, very dynamic, and concise - in other words, I want it to be a complement to Java, rather than simply a scriptable Java, ala Beanshell. This means that perhaps you wouldn't want to write the entire app in Hecl, but on the other hand, as a language to write quick extensions with, perhaps it's a bit faster/easier to work with.
The most interesting feature at this point is that Hecl is small enough to run on Java-enabled cell phones, even pretty basic ones like my Nokia 3100, which only accepts Java stuff - no symbian. This means that you can code apps with no recompiling, and also make them very dynamic (you could make an app that downloads code, stores it and runs it as needs be).
Also, for the folks who like this stuff, Hecl is still young, so there's lots of room to fiddle with the language itself, and learn about how a scripting language is built [dedasys.com].
Astute observers will note that Hecl is similar to Jacl, but like the poster complaining about Jython getting a little bit out of date... it always seemed like a bit of a losing proposition to me to do a copy of a language in Java, because you miss out, if nothing else, on a *lot* of libraries, and the JRuby/Python/Tcl implementations have always seemed to be playing catch-up.
Ruby/Python + Objective-C (Score:3, Interesting)
My money is that there will be alot of attention passed to GNUStep in the near future as a condender on server side and even client x-platform side app development.
My Ideal web/app server is Free BSD + GNUStep + Ruby and/or Python.
JsD
SISC Scheme and Scala (Score:2, Informative)
http://sisc.sourceforge.net/ [sourceforge.net]
IMNSHO Scheme is so much nicer than Python et al that there's not even a decision to be made here as far as dynamic languages on the JVM.
There's also Scala, which is another statically typed language on the JVM. It is SORT of like Java, and can use Java classes natively, but is about 20 times more pleasant to use than Java (if you're into higher-order functions and pattern matching and that kind of thing... but then
Re:SISC Scheme and Scala (Score:2)
Of course, that's by design, and there are good reasons to write programs that way. There are all kinds of errors you avoid by not having state variables, especially in concurrent programming. But to most programmers the concept is profoundly counterintuitive.
Re:SISC Scheme and Scala (Score:2)
Not true:
(let ([x 3])
(set! x 4)
x)
=> 4
Re:SISC Scheme and Scala (Score:2)
There are things that turn people off from Scheme, but that's not one.
Allergy to parentheses is one. That's a fault of the user.
Lack of a consensus on portable interfaces for things outside the Scheme world is another. That's a fault of the Scheme community.
Groovy seems to be dead (Score:1)
http://jira.codehaus.org/browse/GROOVY-1194 [codehaus.org]
This bug is pretty serious and it was filed 4 months ago. No reaction so far.
Nice (Score:2)
Re:Nice (Score:1)
Re:Nice (Score:2)
Nice is a little faster, more lightweight, and deviates less from Java than Scala, making it a hell of a lot easier to get to grips with. Like Scala, Nice supports closures, is statically typed, and integrates perfectly with Java (as do most JVM-based languages). It's been a while since I to
Re:Nice (Score:1)
Unfortunately, I didn't use Nice so far, so I can't comment on speed. However, I can't say Scala code was too slow, except maybe for the compiler :-). Although Scala has no 'nullable' types as Nice, they can be emulated using the Option class (heavily used in the library). For the latter point, indeed, Scala can not inject methods into existing classes, but up to a point, they can be achieved using views [scala.epfl.ch].
An interesting comparison
Re:Nice (Score:2)
Sometime I really have to get around to writing some code in Scala, but currently I'm finding my attention diverted by dynamically typed language. Alas, my spare time to investigate new computer languages is quite reduced these days.
As for speed, I should c
Judo? (Score:1)
At first, it seemed perfect (Score:2, Funny)
After a few months we were at abt. 85% done and then the shit hit the fan. I walked into the development room and then I heard this strange computer voice saying:
"Who the fuck are you?"
And I said, "I'm Cerberusss, and who the fuck are YOU?"
Computer: "I'll tell you who the fuck I am. I'm GroOOOOovy! Punch the green button!!"
At that point, I wa
Re:At first, it seemed perfect (Score:2)
bash (Score:1)
The ultimate "scripting" language is of course.. bash... or zsh. As long as you don't need to do too much math, you can do fairly complicated things in bash and do it *fast* by virtue of the fact that everything you do just launches a native binary, usually written in c, that's specialized for performing whatev
Indent (Score:3, Funny)
Groovy project manager says "don't change" (Score:1)
I just saw this yesterday. Guillaume Laforge the project manager for Groovy
said if you already know python stick with jython if you don't have a reason to change.
Rhino / ecmascript. (Score:2, Informative)
What particularly attracted me to rhino (apart from being a bit of a js nut) was the security model. That is to say, it has one, and it's pretty well worked out. It's typically nontrivial to add sandboxed scripting support to an appl
Groovy is cool but ... (Score:2)
Main reason: the syntax and the class library of both scriptiing languages is: Java. Further more both languages allow you to type your variables (but as in most scripting languages types are optional, while Jython is always typeless --- and besides the wiered syntax of python, the main reason I don't use it: its variables are dynamic typed)
Groovy has disadvantages however. When groovy was "young" it was a v
Jacl! (Score:2)
http://tcljava.sourceforge.net/docs/website/index
I also enjoy just using Javascript for this kind of thing. See the Rhino project:
http://www.mozilla.org/rhino/ [mozilla.org]
SISC and SISCweb (Score:2)
For something different, you'll find SISC [sf.net] brings actual new expressability to the Java platform, rather than just scripting the same old stuff. This lets you do radically different things, as demonstrated by SISCweb [sf.net], which allows you to write web applications without dealing with the stateless, page-centric nature of HTTP.
Plus, you'll learn Scheme, which will make you a better programmer.
Speaking from experience (Score:1)
Everyone overemphasizes the language (Score:5, Insightful)
Pnuts (Score:1)
Re:Esoteric languages (Score:2, Informative)
Groovy does offer things they don't, primarily the ability to compile to class files so that Groovy classes can be used from Java classes and vice versa. This also allows Groovy to run at high speed (as the byte code in the class files is optimised at run time).
However, JRuby plans to allows this in the near future as well.
Re:Esoteric languages (Score:2)
Jython has this feature [jython.org].
Below are two bullet points from the linked page:
Re:Esoteric languages (Score:2)
Below are two bullet points from the linked page:
* Dynamic compilation to Java bytecodes - leads to highest possible performance without sacrificing interactivity.
* Optional static compilation - allows creation of applets, servlets, beans,
I didn't realise that - this looks powerful, although translating via the production of Java source may not be the best way to get high performance. Some of the other languages on the VM
Re:Esoteric languages (Score:1)
Why? Do you have a better approach in mind?
Java source generation is seen only in static compilation. No source is generated while the interpreter is run.
Re:Esoteric languages (Score:2)
Why? Do you have a better approach in mind?
Java source generation is seen only in static compilation. No source is generated while the interpreter is run.
Yes, there is a far better approach - statically compile directly to optimised bytecode. I believe this is what the JRuby people are planning to do.
Re:Esoteric languages (Score:2)
First of all Groovy is Java. Neither Ruby nor Jython is that. So it offers far mroe than both the others. Also in my eyes Ruby is obscure and as well Pythons is
Finally: both use their own libraries (e.g. collections) while Groovy sues the java.util.* classes.
angel'o'sphere
Groovy is not Java (Score:1)
Re:Esoteric languages (Score:2)
Eh? Type is pretty fundamental to variables in both languages. I'd like to see a case of a variable in either one not having a type.
I assume you mean there's no syntax built directly into the language to perform type checking. I see it more as the language doesn't force me to type-check every single variable I use in a program. Static code analysis is a continuum, I could just as easily accuse Java
Re:Esoteric languages (Score:2)
I assume you mean there's no syntax built directly in
You assumew correct. As I wrote: giving avariable a type. I wrote giving, not having.
The article is about why is groovy a good scripting language for Java
I know that Python variables have a type
angel'o'sphere
Re:Esoteric languages (Score:2)
You're not really giving variables types in Java, either, their type is intrinsic upon construction. All you're doing is constraining what variables a reference may point to at compile-time.
I'm being nitpicky because this terminology gets thrown around a lot when talking about static vs. dynamic languages, and it's too imprecise to capture the details of the differences. The difference between Groovy and Python is that Groovy supports sta
Re:Is this usefull ? (Score:2)
Because you may implement a framework of object functionality in Java, but then want to allow developers to write scripts to drive your framework.
QED