Discussions

News: JCP Approves Groovy Language JSR: Sun endorses language

  1. The JCP has approved JSR 241, the Groovy Language. The entire executive committee voted yes, with Sun adding a very positive comment: "Sun is happy to see Groovy proposed as a JSR. Having additional interesting languages for
    the Java platform seems like a Good Thing!"

    This JSR sets a huge precedent. Sun has really shown that they care a lot more about Java the platform, as apposed to just Java the language.

    This is great news for the community. There was also a rumor that James Gosling himself said: "Groovy is groovy" and that he pushed for the JSR to go through.

    View the results of the JSR 241 Ballot

    View the JSR 241 home page

    Threaded Messages (26)

  2. Good work! Interesting timing with recent posting by Mike Spille about using the Groovy language. With the passing of the JSR, does this effectively mean Groovy is the official scripting language for Java?

    Michael
  3. Ghorrr!

    You're looking for controversy Michael!

    Graham (on behalf of Sun's) comment is kinda interesting isn't it. Well if Groovy can be made into a ship-shape well engineered _and_ agile language then all the better. Also MS have loads of langauges for their platform so I imagine it's a flower in the cap for Sun if they can add one 'officially' to their platform.

    I think Sun's 'approval' is a good thing, any new 'agile' (for want of a better word) langauge needs some serious patronage if it's going to get used in most of our working lives.

    Regards
    Neil
  4. Quite a sweeping approval... Congratulations to James and his team!

    --
    Cedric
  5. if the shoe fits...[ Go to top ]

    You're looking for controversy Michael!
    I wasn’t intentionally looking for controversy and if I was I don’t think that is necessarily a bad thing. But I have noticed the absence of the equivalent of say VB in Java. So I was wondering (in the perception of other Java programmers) if Groovy fits that sort of shoe. I hope it is a “flower in the cap” and that other scripting languages come out. I forgot about PHP but then again, I have not used it (read about scalability issues). Speaking of, how does Groovy compare to PHP? Are they apples and oranges?

    Best regards,
    Michael
  6. if the shoe fits...[ Go to top ]

    Now we are close to admit that we have several competing OS:
    Linux, Java and Win(.NET is just next version of MS OS)
  7. if the shoe fits...[ Go to top ]

    Speaking of, how does Groovy compare to PHP?
    > Are they apples and oranges?

    PHP has quite impressive function library written in C. It's also very straight forward to use. Some say that you can program with PHP the way you think. I have got this feeling very often when I have worked with PHP. For example if I want 32-byte hex-decimal md5 output from something, I just call md5("something");, and these cases pop-up all the time. When doing something similar with Java I have to read api documentations and find my way out of overly complicated and abstracted Java implementations. Usually I end up with some utility class that has static method that performs the thing I want. It's quite sad that I almost always end up writing those same utilities over and over again. With PHP, this is not the case.

    Right now Groovy, in my opinion, is nothing more than a new syntax. It has some shortcuts that make programming simple Java programs easier (than doing them in Java), and it has it's uses in some projects (embedded scripting in java environment, quick prototyping of Java apps, etc.). But I think that Groovy needs some PHP like utilities (maybe done in OO ways) to become something more than a syntax. Every scripting language has these (I mean libraries specifically designed for the scripting language itself). Groovy takes another approach by leveraging J2SE and J2EE etc. standard Java libraries (correct if I'm wrong). What I would like to see is that Groovy implements it's own libraries that wrap/reimplement Java libraries to make the most common things as simple as possible.

    Just thoughts.
  8. if the shoe fits...[ Go to top ]

    What I would like to see is that Groovy implements it's own libraries that wrap/reimplement Java libraries to make the most common things as simple as possible.Just thoughts.
    Groovy actually does just this. For example it extends anything that implements java.util.Collection with an each method so you can do things like:
    collection = [1, 2, 3]
    collection.each { print it }
  9. if the shoe fits...[ Go to top ]

    Yep. For comprehensive details, see:

        http://groovy.codehaus.org/groovy-jdk.html

    Most interesting to me are the ones in *Writer/*Reader, *Stream, Object, String, and of course the various Collections. You gotta love things like Reader.eachLine(), Reader.readLines(), and BufferedReader.getText(). Being able to say:

        InputStream is = new FileInputStream (...some file...);
        List file = is.readLines();

    and getting a List of the lines in the file is extremely convenient for scripty purposes. And being final able to say something like this is just excellent:

        InputStream is = new FileInputStream (...some file...);
        is.eachLine ( {
             // Closure with 'it' parameter containing each source line
             // in successive calls.
         });


         -Mike
  10. does this effectively mean Groovy is the official scripting language for Java? Michael
    I dont think its anyone's intention for it to be the official scripting language. Just an official scripting language...

    -Nick
  11. Re: JCP Approves Groovy[ Go to top ]

    This is long overdue. Unfortunately Sun/JCP isn't driven by community demands, but by pressure from Microsoft.
  12. ver y nice[ Go to top ]

    It's soo cool to see that SUN has received groovy as j2EE languaje.
    I was really thinking that java would be the only one for j2ee, but
    sun has surprise me.
    It's great!
  13. Congratulations groovy!

    Somehow I think this will be the shortest bile to follow up bile in the history of Hani. But you know you've made it when Hani's ulcers start acting up.
  14. Just curious as to what advantage does groovy have over other scripting languages that run on the JVM, such as JPython or JavaScript?

    I am interested because I have been using JavaScript with XWork to script my business logic. I like JS because I then have one scripting language for both the client and server, and as I also do some Flash MX work, which uses ActionScript (ECMA script).
  15. Just curious as to what advantage does groovy have over other scripting languages that run on the JVM, such as JPython or JavaScript?
    I guess the different is JPython/JRuby/etc is running on a scripting engine that itself running ontop of the JVM. So virtually the script you wrote will be interpreted twice ;-)

    While Groovy is compiled into Java bytecode, which is the same as compiled Java source to the JVM.
  16. I guess the different is JPython/JRuby/etc is running on a scripting engine that itself running ontop of the JVM. So virtually the script you wrote will be interpreted twice ;-)While Groovy is compiled into Java bytecode, which is the same as compiled Java source to the JVM.
    This is implementation details, some "old" scripting languages are compiled into Java bytecode too, see dynamicjava or javascript, it is not the major feature and it not performant in some cases.
  17. Hello,

    > Just curious as to what advantage does groovy have over other scripting
    > languages that run on the JVM, such as JPython or JavaScript?

      Allow me to highlight my Groovy talk slides (40+) online in an all-in-HTML-page version titled "Groooooovy Babe: Jazzing Up Plain Old Java".

      To quote from the slide titled "Why Groovy? What's wrong with Python (Jython), Ruby (JRuby) or Smalltalk (Bistro)?"

      Why yet another scripting language?

      * Groovy builds on (reuses) the Java standard class library; Python, Ruby or Smalltalk include their own batteries (that is, standard libraries)
      * Groovy uses a Java-like syntax; easy to switch from Java to Groovy or from Groovy to Java
      * Groovy compiles straight to standard Java bytecode; you can use Groovy (groovyc) as an alternative compiler to javac
      
      - Gerald
  18. Groovy builds on (reuses) the Java standard
    > class library; Python, Ruby or Smalltalk
    > include their own batteries (that is, standard
    > libraries)

    Likewise Groovy has to reimplement/wrap several (or all) J2SE /J2EE etc. libraries to make them even remotely usable in scripting environment (eg. Collections, Readers (allready done) and this list should continue to contain most of J2SE classes (not yet done) -> meaning Groovy has it's own standard library). If they are not going to do that, then Groovy gives a little over plain Java.

    > Groovy uses a Java-like syntax; easy to
    > switch from Java to Groovy or from Groovy
    > to Java

    So does C++, C#, JavaScript and many others.

    > Groovy compiles straight to standard Java
    > bytecode; you can use Groovy (groovyc) as
    > an alternative compiler to javac

    That's what all other 30+ JVM scripting languages have done for ages.
  19. That's what all other 30+ JVM scripting languages have done for ages.

      First, I'm not a Groovy fanatic and you're free to choose whatever scripting language you think is best. I've even assembled a Scripting Languages for Java page over at the Viva! site.

      Anyway, even though most scripting languages compile down to bytecode Groovy goes further. If I may quote from the "Compiling Groovy Scripts Using groovyc" slide:

      Note, that every Groovy class becomes a "normal" Java class that you can use inside your Java code. The only difference between a Groovy generated Java class and a plain old Java class is that a Groovy generated Java class supports the groovy.lang.GroovyObject interface.

      - Gerald
  20. Critizizing[ Go to top ]

    you're free to choose whatever scripting language

    Of course (I'm not an idiot). I just wanted to critizize Groovy (I did try to do it in a constructive manner).

    > Compiling Groovy Scripts Using groovyc

    I don't see how this differs from eg. (except that Groovy implements GroovyObject):
    http://jython.sourceforge.net/cgi-bin/faqw.py?req=show&file=faq06.001.htp

    I have to admit that Groovy has more elegant Java bindings than other similar projects, but Groovy without it's own libraries (J2SE doesn't fit, in my opinion, in scripting environment) is just another syntax.
  21. Critizizing[ Go to top ]

    The classes genererated by groovy and beanshell 2.0 are
    real java objects -
    one can use reflection on them to get the methods / fields.
    This is very usefull for intergrating with other systems, for
    example with ant, it is easy to write ant tasks in groovy
    or beanshell.
  22. I attended a presentation on Groovy at a Java conference recently, and the big surprize for me was that Groovy was a compiler and not an interpreter. I've used Perl, Java, and played with BeanShell, and when I heard of Groovy as a standard "scripting" language I just assumed it would be an interpreter, since for me the joy of using a scripting language, aside from loose typing, is switching from the edit/compile/run mode into the more comfy and streamlined edit/run.

    Seriously, when I think of working with JavaScript and being able to make a change, save it in the editor and just refresh my browser to test, versus (for example) working on Struts Action code and having to re-compile it and redeploy it to the app server, I think the interpreted approach wins hands down for programmer productivity. At least it seems so to me, and so when I realized Groovy was still a compiled language might first thought was this was a big mistake and if Sun wants something that truly *complements* Java they would have better chosen something more like BeanShell (i.e. an interpreted Java with optional loose typing features).

    Am I making too much of this? Are they planning to do things analogous to the way JSP's are auto-magically compiled to make it feel more like an interpreted scripting language? Or am I wrong to think of compilation as a significant headache?

    I don't think I'm wrong - but I'm curious what others think. Obviously there's smart people who approved this JSR. I just think practically and politically something like BeanShell would have been a better "standard" Java scripting language.
  23. Darren, yes it's compiled, but if you want to use it in a scripty way you often can't tell that it is.

    Groovy ships with a wrapper program (called 'groovy' :-) that lets you execute scripts directly. Well, you're not really doing it directly but it acts as if it does. It's not exactly like, say, perl, but it's close enough so that you can't tell the difference most of the time.

    So it's easy to just say:

        groovy myscript.groovy

    or to use Unix #! notation:

        #!groovy
        // Groovy code

      -Mike
  24. You're right that is pretty slick - does make it look just like other scripting languages when running from the command line. There's two other modes I'm curious about though:

    a. Embedded usage/"Eval": e.g. I'd like to embed Groovy snippets to act as Struts actions, and iteratively refine/debug them (i.e. edit/test/edit/test quick quick quick - i.e. no headaches/slowdowns from app server redeployment).
    b. Interactive usage: e.g. The "shell" in "BeanShell" is that it literally has an interactive shell, where you can interactively develop and debug programs from this BeanShell "command line". Great for learning and debugging.

    Do you know if Groovy can work in these modes?
  25. On a), yeah you can embed Groovy, but it's a little wordy right now. You have to instantiate an object (GroovyShell?) and you pass the script into that. This should let you do what you want though.

    On b), there's Groovy shell (groovysh) and a simple Swing app groovy console that act as an interactive shell. They're very basic though - personally I find them kind of annoying. It's easier just to write scripts in an editor.

        -Mike
  26. Thanks for the info Mike. Overall sounds real good.
  27. Good Luck!
    ...but this is the beginning of the end!...Playing with the same model of Microsoft (Groovy==VB&family) is not the answer!...
    However show must go on!