Slashdot Mirror


Groovy JSR: A New Era for Java?

fastdecade writes "Groovy, the open-source scripting language, has been submitted for a Java Specification Request (JSR). And not without strong support from venerable J2EE practitioner/author, Richard Monson-Haefel, who labels this "the beginning of a new era in the Java platform". Groovy can use Java objects easily and compiles to JVM byte code, but it is nonetheless a scripting language at heart and a great companion for the more heavyweight Java programming language. Most JSRs concern new APIs, and this is the first JSR for an alternative language. Imagine a common platform of standardised languages talking to each other ... this looms as a big threat to .Net and a rejuvenation of the Java platform."

32 of 100 comments (clear)

  1. wasn't it that... by whathappenedtomonday · · Score: 2, Insightful

    java can only succeed if the runtime is part of consumer OSs? right now, I think it is not... . probably got this one wrong, dunno...

    --
    I hope I didn't brain my damage.
  2. Imagine.... by argel · · Score: 4, Informative
    Imagine a common platform of standardised languages talking to each other ...

    You mean like Parrot?

    --

    -- Argel
  3. bah by Tuxinatorium · · Score: 2, Interesting

    this isn't nearly as revolutionary as the article spins it as. .Net will continue to gain ground solely because of microsoft's promotional dollars, regardless of its merits as a language.

    1. Re:bah by jone1941 · · Score: 3, Informative

      Ugh, Interesting? Common moderators .Net IS NOT a language, it is a peice of marketing. You can wax philosophical about C# or the runtime, but don't make sweeping statements that don't mean anyting. Sorry for the rant, but this post just didn't even make sense, let alone say anything remotely interesting.

      --
      Fear trumps hope and ignorance trumps both
    2. Re:bah by hak1du · · Score: 2

      .Net will continue to gain ground solely because of microsoft's promotional dollars, regardless of its merits as a language.

      C# and the CLR will gain ground because they really do have considerable more technical merit than Java. They will also gain ground because there is a complete open source implementation available (there aren't for Java). .NET is a set of Microsoft-proprietary APIs. It will gain ground because Java doesn't address the needs of Windows programmers as well. Windows programmers aren't going to put up with Java if it doesn't solve their problems as well (which it doesn't).

  4. Isn't this more a threat to Perl than .Net? by ObviousGuy · · Score: 5, Insightful

    Having a glue language to tie together Java objects is definitely cool, as is having the scripting language compile down to bytecode for easy deployment.

    I guess in some obscene way, one could infer that Java is somehow a threat to .Net because its set of tools has grown a little, but Groovy itself seems to be more a threat to Perl and Python and other scripting languages rather than anything Microsoft is doing (except for WSH, but is anyone really using that?) Having a scripting language that can reach directly into Java bytecode without having to invoke a separate VM is a great improvement over the current methods of running external Java programs.

    Frankly, to me, it doesn't matter which 'platform' succeeds. Both frameworks exist on many platforms, so whichever wins, we all benefit.

    --
    I have been pwned because my /. password was too easy to guess.
  5. Let Me Get This Straight by Markus+Registrada · · Score: 4, Insightful
    This is like Python, except it's less portable (because JVMs are less widely ported than Python), and has a bigger memory footprint (because it uses JVM garbage collection instead of Python reference-counting), and it uses libraries with different actual semantics and different bugs on different platforms (because they're the Java libraries).

    It sounds to me like anywhere you think you want this, you would be better off with actual Python.

    1. Re:Let Me Get This Straight by Anonymous Coward · · Score: 5, Interesting

      This is like Python,

      Except it's actually elegant, based on Smalltalk, not whatever the heck Python is inspired by.

      And Python reference counting stinks, I just spent weeks debugging a C extension that keeps killing a Python-based server.

      I use Python, but I sure don't think there's anything "great" about it, at least not enough to explain why it seems *every* language discussion includes somebody who thinks Python is god's gift to computer science.

      Python came along at a time when people where starting to use Perl for bigger projects and realizing that Perl is really BAD for big projects. Momentum took over from there.

    2. Re:Let Me Get This Straight by malachid69 · · Score: 4, Insightful
      it's less portable (because JVMs are less widely ported than Python)

      What platforms is Java NOT ported to?

      I know it is available for Windows, Linux, FreeBSD, AIX, HP-UX, Solaris, AS/400, Handhelds (Palm, Handspring, SaveJe, etc), and direct hardware (PTCU and TINI)... What's missing?

      --
      http://www.google.com/profiles/malachid
    3. Re:Let Me Get This Straight by FFFish · · Score: 4, Informative

      It's even less like Python, because Python has a port named Jython which... you guessed it! provides Python scripting within Java.

      --

      --
      Don't like it? Respond with words, not karma.
    4. Re:Let Me Get This Straight by Pengo · · Score: 4, Insightful

      "It sounds to me like anywhere you think you want this, you would be better off with actual Python."

      Unless you want access to any of the miriad of Java libraries that are available, such as JDBC drivers, XML parsers, SOAP tools and 3rd party components you may want to use unless you prefer to use something like Jython.

      I have to work with other bits of code and systems all the time, and thats the main headache with using Python that I run into.

      Python might be king of quick hacks, but for a large-scale project where bits of scripting code might be appropriate, this sounds like an excelent option where you would NOT be better off with python.

    5. Re:Let Me Get This Straight by stefanlasiewski · · Score: 2, Informative

      Something wrong with this Java?

      http://www.apple.com/macosx/features/java/

      --
      "Can of worms? The can is open... the worms are everywhere."
    6. Re:Let Me Get This Straight by Jerf · · Score: 3, Informative

      such as JDBC drivers, XML parsers, SOAP tools and 3rd party components

      Semi-check, built-in, check, and check (including a lot of real winners, particularly including multiple cross-platform GUIs).

      (The semi-check is because I'm not 100% certain the python modules match the JDBC completely.)

      The only advantage Java offers is when it has an actual library that you can't get in Python (or likely anywhere else); capability for capability the languages and libraries are pretty close to the same. I mean, we have "Web Application Servers" for Python (like Zope), but maybe you absolutely need some Java thing for some other reason. There's no one language that meets all needs. But there's no reason Python can't be used in very large scale projects successfully, as evidenced by the fact that it has been so used.

      Personally, I'd much rather use Python for the larger scale projects since for a variety of reasons I think it scales better then Java; Java projects IMHO survive because they get a lot more resources thrown at them, not because the language does very much to hold large projects together. But that's just my opinion.

      (Oh, and Jython, though I know it's been mentioned elsewhere.)

    7. Re:Let Me Get This Straight by hak1du · · Score: 3, Insightful

      Except [Groovy] actually elegant, based on Smalltalk, not whatever the heck Python is inspired by.

      I don't see anything "elegant" about yet another scripting language built on top of a runtime designed for a simple statically typed language (Java).

      And Python reference counting stinks,

      True. It also makes the C-Python interpreter slower than a garbage collected version. It is somewhat disconcerting that this misfeature of C-Python still exists after so many years. In fact, the C-Python implementation has a number of other weak points. But it works well enough, and it sure is a lot more practical than running a JVM just to execute Groovy.

      I use Python, but I sure don't think there's anything "great" about it,

      Neither do I--Python is just one of many scripting languages. But between Python and the available alternatives, I think Python still is the best of the bunch. A JVM-only language like Groovy isn't even worth talking about.

    8. Re:Let Me Get This Straight by hak1du · · Score: 2, Interesting

      Unless you want access to any of the miriad of Java libraries that are available,

      No, I don't.

      Python might be king of quick hacks, but for a large-scale project where bits of scripting code might be appropriate, this sounds like an excelent option where you would NOT be better off with python.

      There are plenty of scripting languages for that. Jython and JavaScript have both C and JVM-based implementations. Beanshell is small and integrates particularly well with Java. I really don't see why we need Groovy.

    9. Re:Let Me Get This Straight by angel'o'sphere · · Score: 3, Interesting

      But it works well enough, and it sure is a lot more practical than running a JVM just to execute Groovy.

      I like to point out that running Groovy in a JVM means: you want to script java code.

      I also do not really see the difference between running a PVM or a JVM (python virtual machine versus java virtual machine).

      But: I know that Java Byte Code is Hot Spot compiled to machine code. A groovy script running in a JVM scripting Java classes or classes of other languages (like SmallTalk or Lisp or Prolog or Eiffel or Ada or: Python) is java byte code, isnt it? So it is compiled to machine code during runtime.

      Goovy is an excellent language. And in case it gains momentum like one has written here, there is no doubt that people will port it to Parrot and the Python VM just like Python is ported to the JVM.

      angel'o'sphere

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
  6. *blink* hey this is COOL by Anonymous Coward · · Score: 5, Interesting

    As a hardcore Ruby lover, I've been unhappy that I can't use Ruby with the vast libraries available for Perl and other established libraries.

    But this groovy thing looks like a really nice smalltalk-esque language that hooks right into Java, enough to satisfy both sides of my brain.

    This is cool and I can benefit from this *right now* in my work. Forget Parrot or Perl 666 (heh).

    How come I never heard of this? And why doesn't jpackage have it?

  7. rejuvenation? by sfjoe · · Score: 4, Insightful

    ...and a rejuvenation of the Java platform.

    I think people who make statements like this aren't really aware of how widespread the usage of Java is in enterprise and multi-tiered systems.

    Java is not just applets.

    --
    It's simple: I demand prosecution for torture.
    1. Re:rejuvenation? by iradik · · Score: 2, Funny

      yah, but it's so corporate, bleh.

      it's about time cool programmers stepped up on the java scene.

  8. JCP naming thunk? by Tailhook · · Score: 3, Insightful

    Hopefully the name will get changed prior to getting this into the JSE platform. Does it bother anyone else to imagine having to talk about something called Groovy in a professional environment? The Groovy site is chock full of cuteness about making this or that more or less "groovy". I don't mind it personally but it's not helpful when you expect non-technical types to have faith in stuff.

    Anyhow, the JSE platform could use an implicit scripting language. I can see the technical merit in this. A Groovy based shell (with exceptions, an abstract file system, all the JDBC goodness integrated, etc.) that works right everywhere would be a nice bit of progress.

    --
    Maw! Fire up the karma burner!
    1. Re:JCP naming thunk? by lmh2671772 · · Score: 2, Funny
      Hopefully the name will get changed prior to getting this into the JSE platform.

      I guess you could call it Javascript.

  9. Blocks! by OmniVector · · Score: 2, Interesting
    When i saw how Groovy does blocks, i immediately thought of Ruby. basically you have a block of code like this:

    array = [ 1, 2, 3, 4 ]
    array.each do |i|
    puts i
    end


    which outputs 1 2 3 and 4 on a line. the cool thing about this style of coding is it makes it's very easy to extend functionality like this to hashes such as:

    hash = { 1 => "one", 2 => "two", 3 => "three" }
    hash.each_pair do |key,value|
    puts "#{key} = #{value}"
    end


    notice how that code was able to do that much, without having to use "special" syntax like perl and php (foreach blocks, etc).
    i definitely will have to give this language a shot.
    --
    - tristan
    1. Re:Blocks! by Unordained · · Score: 3, Insightful

      would you mind explaining in what way

      hash.each_pair do |key,value|

      is not "special" syntax, but

      foreach ($array_name as $key_name => $value_name)

      is?

    2. Re:Blocks! by tunah · · Score: 2, Informative

      each_pair is a function call that takes a block (like an inline method). Obviously you need language support for passing blocks to functions, but this is a general purpose feature that is used in many places. In contrast, foreach is a (useful) hack for the specific case of iterating over a collection.

      --
      Free Java games for your phone: Tontie, Sokoban
    3. Re:Blocks! by battjt · · Score: 2, Informative

      We do a similar thing in Java with anonymous classes.

      new StopWatch(2000) { public void run() {
      frozzle(blah);
      }}.start();

      where StopWatch is a class that executes the run method for up to 2000 ms. Granted some syntactic sugar would be nice.

      I agree with yuour assertion that blocks are extrememly helpful. I was first introduced to them in Smalltalk.

      Joe

      --
      Joe Batt Solid Design
  10. Re:Warning, Obligatory Jython reference ahead by cxvx · · Score: 4, Informative
    Environmental Variables. Java used to have them. But because of the Mac (oS 9 and before, mind younot OSX) it was removed from the language. Instead, we have -D parameters on the command line. Oh Joy. So to run a program with a different config directory than expected I get:

    Actually, as of JDK 1.5, System.getenv() is undeprecated (is that even a word? :). I'm sure that was a first in the java libraries though :)

    --
    If only I could come up with a good sig ...
  11. Scripting with .NET by Chester+K · · Score: 3, Informative

    Of course .NET already has support for JScript and VBScript -- however, the main problem with scripting on .NET is that once you load code into memory, there's no way to unload it without having to destroy the entire AppDomain.

    This leads to problems where you've got an environment where you'll be running lots of dynamic script code -- your process pretty much leaks memory. The only solution is to run your scripted code off in another AppDomain, but then you've got the considerable overhead of doing cross-AppDomain calls (serialization/deserialization, both ways) and you're restricted to types that can be passed across the AppDomain barrier.

    Even then, you've got to be extremely careful because if you pass back a type that was defined in the assembly generated by the script, your primary AppDomain will silently load the assembly itself to deal with the type (and keep it open forever -- the thing we wanted to avoid!).

    I understand there are considerable performance gains in .NET because of the no-unloading-assemblies behavior; but it makes .NET unusuable in the class of applications where you're running lots of different code from different sources; in this case, a MUD where users can script their own objects -- with the ability to arbitrarily rewrite and change their scripts at any time. .NET seems like it has wonderful support for everything else needed (Code Access Security, etc.), but that one single sticking point is a dealbreaker.

    I'm not all that familiar with this aspect of Java -- does Java suffer from the same problem of not being able to unload code/types from memory?

    --

    NO CARRIER
    1. Re:Scripting with .NET by iebgener · · Score: 5, Informative

      In Java, you can't unload code/type from the classpath (core classes you had when you started java) but if the class comes from a different classloader (created at runtime), you can do pretty much what you want... if you own the classloader...

      The only limitation is that the class must not be on the classpath (for security reason). This is also how you can have the same class but with different version on the same VM.

      See : http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ ClassLoader.html

  12. What platforms is Java NOT ported to? by Tumbleweed · · Score: 4, Funny

    > What platforms is Java NOT ported to?

    Atari 800. It's very frustrating.

  13. what's the point? by hak1du · · Score: 3, Insightful

    Groovy seems to offer nothing that you don't already get in Python, and Python has implementations available based on C (C Python), Java/JVM (Jython), and C#/CLR (IronPython).

    The only thing Groovy does offer is that it is Java/JVM-specific at this point--there are no implementations based on anything other than the Java/JVM runtime. That may be a good thing for Sun--tying people even more to Sun's platform--but it sure isn't good for anybody else.

  14. Great but why a JSR by Laz10 · · Score: 4, Informative

    There are many other scripting languages for java than groovy.

    Beanshell (Lightweight Java)
    http://www.beanshell.org/

    JavaScript (Rhino)
    http://www.mozilla.org/rhino/

    Python (Jython)
    http://www.jython.org/

    Ryby (JRuby)
    http://jruby.sourceforge.net/

    has all been available for several years without being made a JSR.

    What qualifies groovy to become a JSR instead of them ? Isn't choice good.

    IBM has open sourced a framework called BSF
    http://jakarta.apache.org/bsf/
    that allows for integrating scripting languages into java. I could see why THAT would be promoted to a JSR -- not a specific scripting language.

    As the name suggests it looks like groovy is just a couple of guys who have been playing around with tossing "groovy" language features into their homegrown scripting langugage. Cool, interesting but why make it part of the big package ?

  15. Thoughts on the Atari 800 by Tumbleweed · · Score: 2, Interesting

    It was just a joke. :)

    I've become rather fascinated of late with the Atari 800, and with what "could have been," had it been upgraded properly.

    The Atari 800 was the brainchild of Jay Miner (who later created the Amiga), and you can see the Atari 800 really _was_ the precursor to the Amiga, with its use of coprocessors for video, sound, & memory management, in addition to the CPU. The only thing that hobbled the Atari 800 was its expandability, or, lack thereof. Unlike the Apple //, the Atari 800 had no expansion slots, and the memory was only expandable to 48K (though it used VERY easy to use cartridges to expand memory), despite using a chip that could (in theory) address 256K.

    Later Atari 800 machines (XL & above) wound up being expandable to more than 48K, but the way the machine was designed, software that took advantage of memory over 48K wouldn't work on the original 800s, thus, few software makers took advantage of that ability, understandably wanting to sell products usable on as many machines as they could. Thus, despite several generations of barely-different upgrades to the Atari 800, the line died.

    Too bad. It used a much faster version of the CPU than the Apple or Commodore machines of the day (1.89mHz vs 1 or 1 for the Apple ][ & C64), as well as speeding up everything else by using coprocessors. Had the expandability been better, things may have turned out much different.

    It's also interesting to see people making new software & hardware (!) for the Atari 800 line even today. Bizarre, but amusing. I never had an Atari 800 when I was a kid (I had an Apple //e), but I'm thinking of getting one just to play around with. There are connectors now to hook up your Atari 800 to your PC to store software, etc. on the PC, while still being able to use them on the Atari 800, plus access other hardware on the PC. New OS boot cartridges allow the 800 to start up in 2 seconds. Wish I could do THAT with my Win2k box!