When experienced Java developers hear about Groovy, their first reaction is often, “Oh, no, not another scripting language for Java.” Ian Darwin had the same reaction, until he took a good look at Groovy. Elsewhere, metaprogramming with and without J2SE 5.0.
I like the structure. It looks simple; which is one of the things I like about Jython and it is, well, Groovy.
It looks like Python with curly brackets{yuck!}.
Ruby for java. Now if someone at O’Reilly would produce a book on this thing, it could really get some traction.
Honestly, I see absolutely no advantage of Groovy over Jython, with possible exception of “syntactic familiarity”, or “I love curly brackets”, which is stupid.
no it is actually ruby with brackets.
Anyway when comparing it with other languages such as JRuby or Jthon you have to consider that groovy is a “first class” JVM language in the sense that it does not try to port an existing one and rebuild a library, but it really leverages java one.
Also, it is a JCP.
I mean, it has been accepted as a jsr from the jcp
Jython (and JRuby, for that matter) is no less “first class” JVM language than Groovy. Jython can use all Java libraries easily. Like:
from java.util import Random
r = Random
print r.nextInt()
And how about this:
from javax.swing import JFrame
f = JFrame()
f.size = (200, 200)
f.show()
The third line discovers “setSize” method automatically, and also converts Python tuple to Java Dimension object by applying constructor, by itself. 2nd line and 3rd line can be shortened to:
f = JFrame(size=(200, 200))
Well, I will stop here, as this thread is not Jython thread.
There are some really interesting languages being developed for the java VM. The most interesting IMHO is nice http://nice.sourceforge.net/ . It has advanced features such as named parameters, multimethods, a better type system, anonymous methods, tuples and eiffel-style contracts.
Here is an excerpt from the documentation that I found particulary impressive:
Example 7.1. Block syntax for method calls
//First define the method we’re going to call:
//Like an ‘if’ statement
void when(boolean condition, void->void action)
{
if (condition)
action();
}
//Now exercise our method with block syntax:
void main(String[] args)
{
when(1 > 0)
{
println(“Math is working correctly!”);
}
}
The best thing about nice is that it strives to be totally compatible to java. You can of course use java classes from nice, but you can also use/inherit nice classes from java.
there is another one i think called “sleep” http://jirc.hick org its used to script this irc client.
thats http://jirc.hick.org
yes i am a moron
and why not just stick with normal java compiler/syntax
I did not meant they were not able to use the java classes. I mean why would you want them if not for that
What I meant is that if you’re using groovy its standard library is java’s one.
Jython (or JRuby) have their own library, so you end up with duplication and inconsistency in approaches (wich in python’s case is even more Bad considering Only One Way To Do It).
just a question i’m a sort of java programmer just past newbiee status but don’t know a thing about these.
just what is this scripting languagues?
what can they do that normal java can’t?
a simple explanation would be helpful, thanks!
It is the most Java like and it very simple to learn.
http://www.beanshell.org/
I think Java the Language is ass… but, frankly, I think Groovy is excellent.
Java + Java Platform = “…”
Groovy + Java Platform = fantastico.
I don’t know, its just something about the clean syntax, its tight integration with the Java Platform (using the libraries instead of cooking up an entire list of its own)…
I would like to know two important things, though, that seem to be missing from the Groovy homepage: can Groovy classes be consumed from Java without alot of hoop-jumping, and is the speed of compiled Groovy (groovyc baibee) acceptable?
Groovy has some nice things like closures which act as first class functions. Those features will lure you in and then you will be bitten by the lack of advanced features that you will really want once you taste real programming (i.e. higher order types and first class macros). Groovy is a mess. Don’t deal with less than Ruby (OK, Python if you must) and really consider Scheme or Lisp. Why pretend with Groovy?
Why pretend with Groovy?
Unless you can point to a fairly complete implementation of Scheme of Lisp –or hell anyother language– in Java that is a JSR or otherwise on it’s way to being JCP that provides some of the core benefits of Groovy:
-doesn’t try to port an existling library, even if it is only redirecting to the Java libraries
-compiles to JVM runnable code
-provides a quick, easy-to-use syntax for quick development
I’m an afraid I’ll have to bust out my “TROLL” stamp on yo’ azz.
PS- I’m not too sure I’m happy with Groovy requiring additional libraries at run time. I’d rather it be just a java pre-processor. Perhaps this will get sorted when/if JSR 241 gets accepted.
kap (IP: —.access.uk.tiscali.com):
-it’s less verbose and has some handy syntactic sugar to make it handier for somethings. there is nothing it can do that java can’t. sometimes it just makes things easier. well I guess except for it being interactive. That could be handing for trouble shooting an algorithim or playing with a new library to get a better feel for it.
As for Jython, my biggest complaint with it was that it wasn’t 100% comptabile with Python. If I can’t use all my Python code then might as well wriet a new language. Shame since variables to functions would be *REALLY* handy in writing emulators.
I dont realy like Java that much-
Its a bulky download, closed source and not as fast as C.
All apps I have tried in Java have been slow and prone to conflicts, needing a particular version of Java.
Not that Java isnt a nice language, its just a bit of a pain.
I like python, not that its the best language ever, but its easy to read other peoples code and is nicely intergrated into Blender3D and Paint shop pro, Gimp too for that too.
One thing that matters a lot to me is that a lenguage is mature and has a large user base.
Useually meaning that there are lots of libs for it and you can get help from others.
Ruby dosent seem to be used that much, Perl is nice but mainly good for sysadmin stuff (tho quite comparable to python) and list, I havent ever understood well, never needed to.
You just have to pick a language and learn it, I have picked C/C++ and Python, I like them Both.
Another great way to script Java is Bistro, a Smalltalk implementation for Java. http://bistro.sourceforge.net/ Like most of the other options, you have full access to the Java class library- but with the added productivity of the Smalltalk language, legendary ease of use and simple syntax. Good fun!
Its a bulky download, closed source and not as fast as C.
Java doesn’t have the same problems as C did with companies gouging for expensive compilers so there isn’t really a need for another compiler since you can use Sun’s free-as-in-beer compiler and if you wanted to you could write your own. There is excellent documentation upon Java class files available.
Plus what does the compiler have to do with the language?
The downlaod is not that bad. What is the comparable downlaod for C that includes as many libraries? You’d have to include QT since Java comes with a GUI and so on.
I’ve always ran the newest-and-greatest JVM and never had any problem with any Java application and I use it all the time. Mainly NetBeans and JEdit and for many years. Never had a problem. Perhpas your problem is people using newer classes that aren’t available in the jvm you are using? I’ve never had a backward compatibility problem (Well I used some code once where they had named a variable “assert” and then jdk 1.4 came out… but that was easy to fix).