Slashdot Mirror


Groovy in Action

Simon P. Chappell writes "I missed the partying in the 70's and so was not exposed to the full groovy experience that was available. You could say that I was a late developer (pun intended). Thankfully, I am now able to make up for lost time by learning the Groovy scripting language. For those of you not familiar with Groovy, it is a dynamic language designed to run on a Java Virtual Machine and be easy for Java programmers to work with; it looks very similar to Java and will freely inter-operate with Java objects and libraries. I've been tinkering with Groovy on and off for about two years now; learning Groovy in the old days, prior to this year, was a challenge with all of the design changes that were taking place. Groovy in Action (GinA) is the book that I'd wished was available back then. Dierk König, a committer for the Groovy project, has written this definitive guide to Groovy and after what has seemed an eternity to those of us on the Groovy mailing list, it is finally available." Read below for the rest of Simon's review. Groovy in Action author Dierk König, Andrew Glover, Paul King, Guillaume Laforge, Jon Skeet pages 659 publisher Manning rating 9 reviewer Simon P. Chappell ISBN 1932394842 summary A practical how-to book for Groovy

The obvious candidate for this book is the programmer that wants to learn Groovy. What is less obvious, is just who those people are, because programmers who would find Groovy useful are likely to come from quite a wide selection of backgrounds. If you thought that Groovy wasn't for you, read on and consider whether you may have judged in haste.

Current, or former, Java programmers will love Groovy and they will likely make up the greatest proportion of the readership. They will especially appreciate the interoperability of Groovy with Java: your Groovy objects are Java objects, right down to the bytecode level.

As a dynamic language, Groovy attracts a good quantity of the traditional users of scripting languages. Expect to see more than a few system administrators and build managers pick up on Groovy as they realise the benefits it brings. Further sweetening the pot, for build managers, is the ability to use Groovy as a scripting language within Ant. Another group of readers may well come from the dynamic language communities. I think that Ruby and Python programmers may well find this an interesting book to help them understand this new arrival on the scene. With the steady maturing of the Grails project, that uses Groovy as it's implementation and development language, even the Ruby on Rails folks might be curious.

For a book that's setting out to teach you a programming language, the structure is fairly standard. The contents are divided between three parts that theme the Groovy Language, the Groovy Libraries and then wrap up with Everyday Groovy. I like the approach of including guidance for using the language after you've learned it, because it acknowledges that the purpose of learning a programming language is to then use it. This is a very welcome development in programming language books; other publishers and authors please take note!

For the purpose of full disclosure: I had been talking to Manning about writing more of a practical how-to book for Groovy, but with GinA being so good, those conversations stopped almost as soon as they got started.

The first chapter is the standard fare of what Groovy is and why you want to use it. This is important material for those who may be new to the language and it's covered very well. Some book's initial chapters can be a little dry, as if the author was in a hurry to get to the good stuff, but here, Mr. König has recognised that the language is in an early enough phase that explaining why you would want to use it is the good stuff.

I'll save you from a big list of chapter headings and just relate that part one covers the basics, including how to compile and run code and how to run it as an interpreted script. The fundamental Groovy datatypes are introduced and we learn about the joys of optional typing, for those occasions when it's not obvious that the object is a duck. Groovy has all the things you'd expect from a dynamic language: strings, regular expressions, ranges, lists, maps, closures, control structures and finally, to make it in the corporate programming world these days, it has objects.

As we skipped chapter headings for part one, I'll follow precedence and skip them for part two as well. Part one taught us the basics of the language, part two looks to help us now integrate with the Java environment and existing Java code and systems. Builders are an important part of using Groovy to it's full dynamic extent and these are covered extensively. Groovy also brings it's own library extensions for the standard Java libraries, and they are known as the GDK, even though they're technically not a development kit. Groovy works nicely with databases and is able to use any existing JDBC drivers you may have. XML, whether you love it or hate it, is a big part of the life of a corporate programmer these days. Groovy has built in smarts for working with XML and you'll learn about those in this part. There are many useful Java tools, libraries and frameworks available today and Groovy can work with almost all of them. Much good information on integrating with everything from Spring to the new scripting interface defined by JSR-223 is covered.

Part three is the Everyday Groovy part. It starts with Tips and Tricks. Things to remember, useful snippets of code, advice on calling Groovy from a command-line, and writing automation scripts. There's also a full chapter on Unit Testing with Groovy, covering testing of both Groovy and Java code. The last two chapters cover optional stuff for Groovy. Groovy on Windows looks at the use of the Scriptom tool for those who use Windows. (As a Mac user, I admit that I skipped this one.) The last chapter is an introduction to Grails, the web application framework written in Groovy and which can run in any standard J2EE environment.

There are a couple of slim appendixes at the back with installation information, language information and an API Quick Reference for the GDK.

There is much to like about GinA. Mr. König and his co-authors writing is clear and engaging and Manning's layout and typography are up to their usual excellent standards. On it's own, these are good reasons to consider this book if Groovy interests you, but when you mix in the fact that Mr. König is a committer on the Groovy project and has taken an active role in the creation of the language itself, then you have a very compelling reason to choose it.

Groovy in Action is an excellent book, written by one of the designers of the Groovy language. If you have any interest in modern scripting languages at all, I would recommend that you check out this book.

You can purchase Groovy in Action from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

154 comments

  1. obvious by User+956 · · Score: 1

    Groovy in Action (GinA) is the book that I'd wished was available back then.

    Is this 'gina freely available in bookstores, or do you have to show ID to see it?

    --
    The theory of relativity doesn't work right in Arkansas.
  2. Finally, Slashdot links to Amazon by Anonymous Coward · · Score: 1, Insightful

    It's nice to see that Slashdot has finally started linking to the Amazon listing instead of the wildly overpriced Barnes & Noble as it inexplicably did for several years. Do, however, take a look at the "Used and new..." listings, since the third-party sellers usually offer new copies even cheaper than Amazon itself does.

    1. Re:Finally, Slashdot links to Amazon by Anonymous Coward · · Score: 0, Troll

      Can someone find and kill this goddamned asslicker?

    2. Re:Finally, Slashdot links to Amazon by Anonymous Coward · · Score: 0

      Oh no, somebody might've spent an extra $2-3, heaven forbid.

      Personally, I'm willing to pay $3 if it means not supporting a known patent abuser.

  3. Biased reviewer, reads like an ad for Groovy by Anonymous Coward · · Score: 2, Informative

    The reviewer is an author of several Groovy articles and has a vested interest in seeing the book succeed. How about a little objectivity and professionalism?

    1. Re:Biased reviewer, reads like an ad for Groovy by Anonymous Coward · · Score: 0

      He acknowledged he's been speaking with Manning about writing his own book on the subject. Also, he's not reviewing Groovy, he's reviewing the book about the language. Chances are, anyone who's interested in this book will be biased towards Groovy. Thirdly, any idiot can write something for a webpage. Congratulations on tracking down the history of this guy. That's what you really wanted to hear anyway.

    2. Re:Biased reviewer, reads like an ad for Groovy by Anonymous Coward · · Score: 0

      A positive review for a book about a language will encourage people to purchase the book and possibly adopt the language.

      Read the review (yes I know this is Slashdot). Out of 12 paragraphs, a full 6 have almost no insight into the book and its quality, but rather discuss various features of Groovy or name-check -- link-check, even -- various Groovy-related projects.

      This is an ad for Groovy, as is the book itself.

    3. Re:Biased reviewer, reads like an ad for Groovy by Anonymous Coward · · Score: 0

      has a vested interest in seeing the book succeed. How about a little objectivity and professionalism?

      I agree. Let's have visual basic programmers review java books as they don't have an "incentive" to see java succeed and they'll know what they are talking about.

      Do you think about anything before posting?

    4. Re:Biased reviewer, reads like an ad for Groovy by Anonymous Coward · · Score: 0

      It'd be one thing if he gave us any information about the book, like, oh, say a drawback or two -- or really anything beyond what we can get from the table of contents. As it stands he spends more time saying what's great about Groovy than what's good and bad about the book.

    5. Re:Biased reviewer, reads like an ad for Groovy by Anonymous Coward · · Score: 0

      The author has written several articles about the relevant topic, and so has "a vested interest"? Then who can be trusted as an impartial reviewer - someone who knows nothing about the subject at all?

    6. Re:Biased reviewer, reads like an ad for Groovy by hey! · · Score: 1

      Yes.

      Henceforth we shall only trust information sources with no first hand experiences.

      Trade mags, here we come! (why is my hair getting pointy?)

      --
      Post may contain irony: discontinue use if experiencing mood swings, nausea or elevated blood pressure.
  4. 70s were crap by Intron · · Score: 1

    I assume the Groovy IDE is in your choice of colors: avocado or paisley

    Startup plays "Disco Inferno"

    Comes with a draft notice for assignment to Korea (coming around again soon!)

    Has built in 300 baud serial modem to connect to a BBS

    --
    Intron: the portion of DNA which expresses nothing useful.
    1. Re:70s were crap by nuzak · · Score: 1

      > Comes with a draft notice for assignment to Korea

      Clearly a product of the US Education system. That, or you don't remember the 70's, in which case this is actually authentic.

      --
      Done with slashdot, done with nerds, getting a life.
    2. Re:70s were crap by LuisAnaya · · Score: 1

      Korea? I though that was over in '54... (Dad served) 'nam finished in 72... although you're right, we may get drafted again, well, I'm old to worry about that. BBS's, C'mon, BBS's were popular in the 80's, in the 70's people were still shoveling cards into a reader to hack some JCL, COBOL or FORTRAN. :D.

      --
      Vi havas e-poston.
    3. Re:70s were crap by Anonymous Coward · · Score: 1, Informative

      Someone is bound to point it out, so it may as well be me:

      Korea War ended in 53.
      Vietnam War ended in 75.

    4. Re:70s were crap by Anonymous Coward · · Score: 0

      To add to the taunts regarding your lack of past U.S. wars, I will include that Paisley is a pattern, not a color... Fact check! This is slashdot! (oh right, i'll be on my way then)...

    5. Re:70s were crap by Anonymous Coward · · Score: 0

      "on July 27, 1953, by which time the front line was back around the proximity of the 38th parallel, and so a demilitarized zone (DMZ) was established around it, still defended to this day by North Korean troops on one side and South Korean and American troops on the other."

    6. Re:70s were crap by Intron · · Score: 1

      Oh stupid me. Also, Afghanistan hostilities ended in 2001 and Mission Accomplished ended in Iraq in 2003. Please let our boys in Korea know that they can come home now. Somebody forgot to tell them.

      --
      Intron: the portion of DNA which expresses nothing useful.
    7. Re:70s were crap by Anonymous Coward · · Score: 0

      As long as we're pointing things out, don't capitalize "war," as congress did not actually declare war on Korea or Vietnam.

    8. Re:70s were crap by TheDreadSlashdotterD · · Score: 1

      I don't think the Korean War ever actually ended, but I do believe the draft did due to a little conflict called Vietnam. You might have heard about it. Now we just send people who want to see the far east.

      --
      I have nothing to say.
    9. Re:70s were crap by blootooth · · Score: 1

      Indeed the seventies were crap. The sixties were groovy. man.

      --
      Do not mistake understanding for realization, and do not mistake realization for liberation
    10. Re:70s were crap by nuzak · · Score: 1

      I may be going out on a limb here, but I think they stopped drafting people for the Korean war before 1970. Perhaps you've got it confused with M*A*S*H.

      --
      Done with slashdot, done with nerds, getting a life.
    11. Re:70s were crap by nuzak · · Score: 2, Informative

      Technically the Korean War never really ended, there's just been a 50+ year ceasefire. We tend to not draft people when there isn't any shooting going on though.

      --
      Done with slashdot, done with nerds, getting a life.
    12. Re:70s were crap by PCM2 · · Score: 1

      Technically the Korean War never really ended, there's just been a 50+ year ceasefire.

      Well, technically it wasn't even a war. It was a "conflict," or perhaps a "police action." It was never declared by Congress.

      --
      Breakfast served all day!
    13. Re:70s were crap by rnturn · · Score: 1

      `Startup plays "Disco Inferno"'

      Good Lord! I lived through the Disco era. It was far from Groovy, believe me.

      `Comes with a draft notice for assignment to Korea'

      Anyone from the '70s (well the early '70s, anyway) would have thought that an assignment to Korea after getting drafted wouldn't be so bad. Better than shipping out to 'Nam, anyway.

      --
      CUR ALLOC 20195.....5804M
    14. Re:70s were crap by Anonymous Coward · · Score: 0

      "We". Gotta love that catch-all lump sum, as if each and every individual living in this country actually makes the decision for himself whether to employ the draft or not. That IS what the term "we" implies -- it certainly doesn't imply an elite few who make decisions and force them on everyone else.

      Really, quit beating around the bush and recognize the fundamental difference between the government and the people: government is the group holding the unique "right" to employ coercion (such as the draft) against peaceful individuals; anyone else who does so ("the people") are called criminals.

    15. Re:70s were crap by Intron · · Score: 1

      You aren't drafted "for a war", you are drafted into the army and they send you where they want.

      --
      Intron: the portion of DNA which expresses nothing useful.
    16. Re:70s were crap by hey! · · Score: 1

      Geez, don't tell them that. Whenever a kid asks about the 70s, I tell them, "Well, on one side, everyone had to wear bell bottoms. But on the plus side, there weren't any veneral diseases that anybody heard about that that couldn't be cured with penicillin, so everybody got all the sex they wanted."

      Keeps them from pitying you for being an old, obsolete codger.

      --
      Post may contain irony: discontinue use if experiencing mood swings, nausea or elevated blood pressure.
    17. Re:70s were crap by nuzak · · Score: 1

      We think that we are inserting some ranting into a post that was never intended to be your soapbox. We are not amused. We think we should increase our medication.

      --
      Done with slashdot, done with nerds, getting a life.
  5. This is only slightly more interesting than... by dotancohen · · Score: 5, Funny

    ...than the Hip Hop programming language. # include numba main { hollar ("Wassup, world!"); giveItUp 0; }

    --
    It is dangerous to be right when the government is wrong.
    1. Re:This is only slightly more interesting than... by Frosty+Piss · · Score: 0, Redundant

      Funny! Mod up. Very funny!

      --
      If you want news from today, you have to come back tomorrow.
    2. Re:This is only slightly more interesting than... by bennini · · Score: 1

      wow! possibly the funniest comment ever on slashdot...granted it may be tied with the recurring jokes about flying monkeys and anal sphincters.

  6. obligatory bruce campbell by flynt · · Score: 0
  7. Trilobyte by TheRealMindChild · · Score: 1

    The computer world is running out of names... when I saw "Groovy", I thought of the engine used in The 7th Guest and 11th Hour. (sorry, cant find the links anymore).

    --

    "When life gives you lemons, don't make lemonade. Make life take the lemons back!" -- Cave Johnson
    1. Re:Trilobyte by Fez · · Score: 1

      I thought the exact same thing, but after looking it up again, the name of that engine was Groovie. I think that Groovie was only used in 11th Hour, though.

      When in doubt for links to 7th Guest and 11th hour info, there's always Wikipedia: http://en.wikipedia.org/wiki/7th_Guest and http://en.wikipedia.org/wiki/The_11th_Hour_(comput er_game)

  8. Similarity To : by Anonymous Coward · · Score: 0


    C#.

    Comments welcome.

  9. Looks like Ruby by Anonymous Coward · · Score: 0, Troll
    except worse.

    import org.apache.commons.lang.WordUtils class Greeter extends Greet { Greeter(who) { name = WordUtils.capitalize(who) } }

    new Greeter('world').salute()

    Ugh. Like Java this gets it all backwards. A string should know how to capitalize itself.

    1. Re:Looks like Ruby by Anonymous Coward · · Score: 0

      Damn...why do people use this again?

    2. Re:Looks like Ruby by charlesbakerharris · · Score: 1

      Yeah! Java classes are too streamlined and lightweight! APIs are too clear! WE MUST MUDDLE!

    3. Re:Looks like Ruby by Anonymous Coward · · Score: 0

      I don't know what the parent is cribbing about. This is how you do it in Groovy:

      string.toUpperCase()

      Snippet FTA:

      Greet(who) { name = who[0].toUpperCase() + who[1..-1] }

      I think this post will soon turn into a "Java is dead" orgy pretty soon.

    4. Re:Looks like Ruby by Zeek40 · · Score: 1

      Java Strings can't capitalize themselves for security and performance reasons. Immutable strings prevent people from mucking with the string's contents while you aren't paying attention (from another thread, or in a subclass of String), and having a constant fixed length prevents unnecessary memory allocation. The class is also implemented as final for these reasons. StringBuffer is the class that should implement the capatalize() function, but unfortunatley it's missing there too. =P

    5. Re:Looks like Ruby by Anonymous Coward · · Score: 0

      I think this post will soon turn into a "Java is dead" orgy pretty soon.
      I certainly hope so! There are very few things in life that are more fun than ranting about how much Java sucks! If you're a programmer, I'd highly recommend the ##java channel on freenode for some great entertainment. You won't find gems like the following anywhere else...

      <meeper> er yeah, again, most programmers don't write algorithms
      <whats_in_a_name>programmers dont write algorithms? come on meeper, youre just saying some stupid shit now
      <meeper> whats_in_a_name: err no they don't. in fact, if I find a programmer writing an algorithm I'd likely fire him
    6. Re:Looks like Ruby by crayz · · Score: 1

      So kind of like Symbol vs. String in Ruby, except less well named and implemented?

    7. Re:Looks like Ruby by Anonymous Coward · · Score: 1, Informative

      A string should know how to capitalize itself.

      This blanket statement is trivially wrong. One day, you will look back and realize that you were quite naive.

    8. Re:Looks like Ruby by Anonymous Coward · · Score: 0

      What the hell is streamlined about Java classes?

    9. Re:Looks like Ruby by kaffiene · · Score: 1

      Ugh. Like Java this gets it all backwards. A string should know how to capitalize itself.

      Strings in Java do know how to capitalise themselves you dick / troll.

      eg:
      myString.toUpperCase()

    10. Re:Looks like Ruby by D-Cypell · · Score: 1

      It would be more accurate to say that java.lang.String knows how to create a capitalised version of itself as Java strings are immutable.

    11. Re:Looks like Ruby by phasm42 · · Score: 1

      Part of the problem with in-place upper/lower case functions is that once you go beyond ASCII, you get into situations where the string can actually change length. One I remember in particular is that the German beta looking character changes to "ss" when you lower-case it.

      --
      "No one likes working in a hamster wheel, and your shop smells of cedar shavings from here." - TaleSpinner
    12. Re:Looks like Ruby by charlesbakerharris · · Score: 1

      lrn2sarcasm

  10. Not obvious enough by Bob+Gelumph · · Score: 3, Funny

    You could have at least made reference to a user group based in Virginia: the VAGinA User Group

    --
    I'm gonna need a spec.
    1. Re:Not obvious enough by User+956 · · Score: 1

      You could have at least made reference to a user group based in Virginia: the VAGinA User Group

      Doesn't that cover nearly half the population? (present company excluded, of course... this *is* slashdot, after all)

      --
      The theory of relativity doesn't work right in Arkansas.
    2. Re:Not obvious enough by Anpheus · · Score: 1

      Well if you didn't fail statistics, you insensitive clod, you'd know that.

    3. Re:Not obvious enough by shmlco · · Score: 1

      Actually, if you stop to think about it from both sides of the equation, doesn't that cover nearly ALL of the population?

      --
      Any sect, cult, or religion will legislate its creed into law if it acquires the political power to do so.
    4. Re:Not obvious enough by User+956 · · Score: 1

      Actually, if you stop to think about it from both sides of the equation, doesn't that cover nearly ALL of the population?

      Yeah, so what we really need is a group for owners, and a group for those of us that just rent.

      --
      The theory of relativity doesn't work right in Arkansas.
    5. Re:Not obvious enough by dgatwood · · Score: 1

      I was thinking "Very Awesome Groovy in Action", which would be somewhat more inclusive.

      --

      Check out my sci-fi/humor trilogy at PatriotsBooks.

  11. wow. by Anonymous Coward · · Score: 0

    why do you hate end users so much? this manifests as nothing more than a way to make java even slower and more painful to run.

    developers - "but it's object oriented!!!!"

  12. Lets invent yet another language! by @madeus · · Score: 1, Troll

    Caution: Mildly flamey (this is liable to really wind some people up, but I'm sure as many will agree :-)

    I don't know where people get the idea that coming up with a new incrementally different languages and ever mote elaborate frameworks, when we have a large number of functional ones already is worthwhile endeavor (outside of academia and research labs). IME, "agile programmers" (the 'paired programming', 'what radical new methodology can we hop on board with this week' variety) are the worst offenders of this sort of thing.

    Languages like C (in it's range of distinct flavors), Java, ASP, PHP, Perl, VB.NET are surely enough for what people are typically doing (which for the vast majority of developers basically, is the same old fairly simple stuff over and over again - web services, XML parsers, and database interfaces). It's simple stuff, my mind boggles at the thought of people *PAIRING* for this sort of thing. If you don't know how to write that sort of thing solidly and reliably WITHOUT pairing and unit testing, you probably shouldn't be writing software in the first place.

    It's not that I'm against people trying things out and moving forward with new ideas.

    For example: It's fair to say that mod_perl is less than ideal (read: pretty kludgy) and people have legitimate reasons for not liking PHP (though with PHP 5's OO support it's getting better) and they have issues with Smalltalk, and so I can see a case for people liking something like Ruby - so I'm not entirely against new languages that only have some fairly incremental improvements over others, as in some cases it's reasonably justifiable (even if I personally don't see the point in Ruby, I can see why other people do).

    But this sort of thing? An "agile dynamic language for the Java Platform" to quote the first line of the blurb on it's homepage. To me, that sounds like someone who prefers playing buzzword bingo to just getting on and doing Real Work. From a brief description of it, I can see something of a case for it, or rather I could if people weren't coming up with a myriad of new similarly arguably-incrementally-more-useful-than-whats-gone -before-in-some-circumstances languages. I just don't think the effort involved in people getting to grips with it and having to support what ever is implemented in it is liable to be worth while.

    When people implement this sort of stuff, they completely discount that developers who come after the people who write this sort of thing (and Java enterprise development is full of contractors - especially in the so-called 'agile' market) will have to look after the mess that gets created. I am highly skeptical that it's more beneficial to jump on the band wagon of some new language or framework rather than just hire developers who can write proficiently in a small number of common and widely supported languages (e.g. C, Java and Perl/PHP - or say C++/C#, VB.NET and ASP).

    It seems these days a large proportion of new developers are primarily one trick Java poneys, with a fondness for frameworks of dubious merit and a lack of appreciation for basic OS fundamentals and established (and functional) scripting languages. Or am I just working in the wrong place? 8)

    1. Re:Lets invent yet another language! by Anonymous Coward · · Score: 0

      You've never done unit testing or pair programming if you think people who do those things are making up for a lack of ability.

      And yes, your elitism comes from one of two places: either a) you're ignorant or b) you work with idiots and are rightfully elitist, so I'd guess you probably are 'working in the wrong place'.

    2. Re:Lets invent yet another language! by Anonymous Coward · · Score: 0

      I guess this would be considered mildly flamey, if there had actually been any meat to it. A disorganized collection of half-assed objections shouted from the pulpit of total ignorance hardly qualifies. Once your in-depth evaluation of the merits of the language gets past the first line of their web site, then maybe your opinion will be worth something.

    3. Re:Lets invent yet another language! by junklight · · Score: 1

      Oh dear.

      you are missing the point about so many things I am just tempted to say *Whooosh* and have done with it.

      From your tone you sound like you think you are a good programmer and yet your opinions indicate that you have a real lack of experience.

      If you are young and new to development - leave your current job. Tomorrow. and go into the world and get some more experience (this is assuming you want a career of some sort). If you are old and cynical stick with it and hope that there is enough work in whatever specfic thing you are good at until you retire.

    4. Re:Lets invent yet another language! by Anonymous Coward · · Score: 0

      Hmm, yeah except that there are plenty of instances where this sort of thing comes in handy. For example, I work as a consultant for a major internet media provider. My company implemented a fairly complex authentication and account provisioning system based on LDAP, and using Java Servlets. All fair and good. Works great. Super fast. Except that the idiots who make their online interface keep completely messing up the XML requests that they send in. They basically poison the database with bad data. To make things worse, the mistakes are in the form of inconsistancies across shared user records. So now I need to make a script that finds all the errors and then formats them in such a way that another script can be used to fix them. Keep in mind that LDAP doesn't support many of the various logical operations that something like SQL has, and everything is output in the form of an LDIF (odd looking text file). Sure I could spend hours mucking about with Perl, trying to get it to unformat the text and then do the operations that I want via LDAP queries. Or I can just use groovy, hit up the Java LDAP frameworks, and get the whole thing done in a trivial amount of time. AWESOME. Seriously, AWESOME. Saved me days of work, fixed everything, was a breeze to use, and came out as a much shorter amount of code than if I had actually done the whole thing in Java (or Perl for that matter). If you're a java developer, Groovy really is teh sh*t.

    5. Re:Lets invent yet another language! by arthurs_sidekick · · Score: 1

      I wondered about why someone would go to all the effort of developing Groovy, and I think it comes down to this: there are Java developers who are fond of the JVM, but don't much care for Java (or at least, not in all situations; maybe static typing gets them down sometimes). Groovy (and JRuby, and Jython) gives them (let's say) dynamic typing without leaving the JVM, with its wide range of libraries and pretty damn good platform independence. You can -- in principle -- drop a few jar files onto your classpath, and access all of your Java-based infrastructure from these languages.

      Groovy, since it was invented as a "scripting language for the JVM" seems less advantageous in this regard than the other two, since there's an existing pool of Ruby and Python documentation and coders who don't have as far to travel. OTOH, as such it might be a better fit for a calcified Java programmer ...

      A related reason is Ruby on Rails envy: there's Grails, and the JRuby gang are focusing on making sure they have RoR support. A slightly different use I can think of for these sorts of frameworks is that they give you the ability to whip up a script that generates a report, or fixes some bad data, or (etc.) and hot-deploy it to your servlet container.

      --
      "Oh, I hope he doesn't give us halyatchkies," said Heinrich.
    6. Re:Lets invent yet another language! by puppetman · · Score: 2, Informative


      I'm not familiar with Groovy - I was came across Bean Shell first, and the reviews at the time found it better than Groovy. Not sure if that has changed or not.

      That said, Groovy and Bean Shell are interpreted scripts written in Java. No compiling to byte code. I look at a Bash script (or PERL script) and often wonder what the developer was smoking when they wrote it. Bean Shell/Groovy are a way to get the power of Java without the overhead (no "static void main (String[] args)") - you can do all those handy little scripting tasks in it. You can pull in all your existing Hibernate libraries, core-components, reusable code quickly and easily.

      Ruby is great, but (to paraphrase Bruce Tate's "From Java to Ruby"), it's not applicable for the hard problems (things that those powerful, compliated frameworks like Hibernate, Spring, EJB, JMX, etc solve).

      Here, you get to solve the small problems in Java without the overhead of writing a full blown program, and you can still access the technology for the difficult problems.

      That said, it's still not Ruby (or Ruby on Rails).

    7. Re:Lets invent yet another language! by ady1 · · Score: 1

      With all the new cores/gpus available and programming getting complex everyday, we do need much more optimized and easier to use languages.

    8. Re:Lets invent yet another language! by Joey+Vegetables · · Score: 4, Informative

      Groovy is not "just another language" competing directly, in the same space, with others. It tries to fill a specific niche that, at least arguably, nothing else filled well, if at all: the ability to do high-level scripting, a la Python or Ruby, targeting the Java VM, and thus being able to inteoperate well in both directions with the Java class library as well as existing Java code. (Note: BeanShell was an attempt to fill a similar niche, but I'm not sufficiently familiar with it to know how well it did so. Jython and JRuby are other attempts, but are mostly existing languages implemented for the JVM, not new languages specifically designed for the JVM environment.)

    9. Re:Lets invent yet another language! by Anonymous Coward · · Score: 0

      Sorry but no. Groovy is much, much, much faster than jruby or jython. A more natural fit with java as well.

    10. Re:Lets invent yet another language! by erinol0 · · Score: 1

      I did the opposite--I tried Groovy first. And it's fine as long as you don't mind huge memory leaks. Granted, this was a year ago, but there was a problem with the Groovy class loader iirc. At the time, the developers weren't very interested in dealing with this problem, and I even invested some time in trying to fix it, but it was a fundamental flaw in the class loading. We switched to Beanshell, and haven't looked back.

    11. Re:Lets invent yet another language! by Anonymous Coward · · Score: 0

      So you chose Java & Groovy out of a concern for performance? Uhh, yea

    12. Re:Lets invent yet another language! by @madeus · · Score: 1

      you are missing the point about so many things I am just tempted to say *Whooosh* and have done with it.

      From your tone you sound like you think you are a good programmer and yet your opinions indicate that you have a real lack of experience. Given the level of inaccuracy of your first statement, you'll forgive me if I don't put much weight in your second. ;-)

      While I'm not an old man by any stretch actually I have quite a bit of experience (long enough to have a five digit /. UID in at least, which is far from impressively low but it's pre .com at least :-), and I get to design and develop some pretty interesting software (for a household name, for a customer base of millions). I'm pretty sure from my own experience and level of demand for work that I 'get it', I really do. YMMV, but I'm not liable to sweat it if you disagree, as I am pretty well valued and, I genuinely believe, have a solid view of my abilities and limitations.

      If you are old and cynical stick with it and hope that there is enough work in whatever specfic thing you are good at until you retire. I don't think being able to write good software and having good fundamentals is "specific" just because I don't care for writing mundane Enterprise software. While those enveloped in it tend to think the modern world revolves entirely around Java[1], "agile methodology" the latest cool frameworks and the latest IDE that's popular with the 'in crowd', such comparatively little really interesting software is written that way.

      I can only assume some people just have no aspirations above writing Java EE software (though I do know some very experienced developers that do it on contract for the money, even though they don't really buy in to the hoopla to the degree that many do). That doesn't excuse the level of religious fanaticism displayed about it though, especially when so many partaking in it have so little comparable experience of developing end products they are happy to point to and say "I did that!".

      [1] Again, not a dig at Java itself. For the most part I like Java.
    13. Re:Lets invent yet another language! by @madeus · · Score: 1


      Hey, thanks for that, that's actually a sane reply that illustrates it's usefulness with a meaningful example.

      That usage definitely makes sense to me (and worse - is not entirely unfamiliar! :-).

    14. Re:Lets invent yet another language! by @madeus · · Score: 1

      *snicker*

      *hugs Java out of sympathy*

    15. Re:Lets invent yet another language! by Anonymous Coward · · Score: 0

      No, I use Java because I build enterprise applications, which is something that J2EE makes rather easy. I use Groovy because it works better (i.e. faster, cleanler, more appropriate to the design)than jython or jruby. It also has the added benefit that somebody who only reads Java can immediatly understand it.
      I think that some posters are approaching Groovy like it sucks simply because it's a new kid on the block. It just went 1.0 less than 2 months ago! When people see how well it fits into their development practice, I don't doubt that it will become an ordinary aspect of Java development. Why? Because it makes other things that people like myself do all the time, that much easier.

    16. Re:Lets invent yet another language! by angel'o'sphere · · Score: 1

      That said, Groovy and Bean Shell are interpreted scripts written in Java. No compiling to byte code

      Thats wrong, most scripting languages on Java are compiled to byte code and later Jitted. and this particular 2 are compiled to byte code, definitely.

      angel'o'sphere

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    17. Re:Lets invent yet another language! by Z0mb1eman · · Score: 1

      That is a REALLY long post to write without knowing what you're talking about.

      (mildly flamey right back at you :p)

      Okay, okay, some substance to my post:

      You talk about "this sort of thing" and "this sort of stuff", which shows pretty clearly that you haven't used Groovy.

      I've used Groovy. I don't really like it, but I use Ant heavily at work, and you run into Ant's limitations very quickly. Being able to use Groovy from within Ant - once you're already within an environment that heavily uses Ant for automation, etc. - is about as elegant as Ant or Java get, and I'm grateful for its existance. See also the excellent Canoo Webtest, which with Groovy support lets you do things you'd find extremely difficult in any other web testing tool. Granted, these are fairly specialized uses, but that's already two only in my limited experience... and it does fill a useful niche in the Java world.

      Your comparison to "C (in it's range of distinct flavors), Java, ASP, PHP, Perl, VB.NET" or "C, Java and Perl/PHP - or say C++/C#, VB.NET and ASP" is REALLY missing the point. I wouldn't be so proud of your 5-digit Slashdot ID if you don't take the time to know what you're talking about before going on a long rant.

      --
      ClutterMe.com - easiest site creation on the Net. Just click and type.
    18. Re:Lets invent yet another language! by Anonymous Coward · · Score: 0

      You'll love my new script language. Its a script language for developing new script languages called BOOKS. Here is an example program

      #declare BOOK name GROR
      #write O'Reily Guide name "GROR: Introduction to Programming for Interactive Distributed Consumer Focussed Interwebs"
      #write slashdot post name "GROR: Great book on Amazon"
      #write check to self
      #declare vacation
      #end GROR

    19. Re:Lets invent yet another language! by @madeus · · Score: 2, Insightful

      That is a REALLY long post to write without knowing what you're talking about.

      I think I know about developing software, YMMV. 8)

      You talk about "this sort of thing" and "this sort of stuff", which shows pretty clearly that you haven't used Groovy.

      It's just a collective term for systems and behaviours being advocated that I'd just described. What infers that I haven't used Groovy is my lack of descire for for Yet Another Programming Language / Framework (specifically, when those new languages frameworks are of very little value over what exists and is widely used already).

      I don't use Groovy because I don't write enterprise software in Java. I do write enterprise software, and I've written a fair bit of stuff in Java (client software and server software), I just don't happen to specifically write enterprise software in Java, for much the same reason as some people evidently want to use glue like Groovy.

      I don't create a senario where I have a problem that necessitates something like Groovy to glue my software together, which seems to be a better approach IMO.

      Your comparison to ... is REALLY missing the point

      I rather think it's hitting the nail on the head.

      I wouldn't be so proud of your 5-digit Slashdot ID if you don't take the time to know what you're talking about before going on a long rant.

      You appear to be suggesting that not buying into to a specific bunch of hoopla means people don't know what they are talking about when it comes to developing software. I have heard that way to many times over the last 10 years (about $latestCoolThingAllThePopularKidsAreUsingNow).

    20. Re:Lets invent yet another language! by Z0mb1eman · · Score: 1

      To each his own then. I understand your dislike of hype, and fatigue with learning new languages/frameworks that do the same things in slightly different ways.

      What I DON'T understand is dismissing Groovy outright because you have no use for it. The right tool for the right job... Groovy isn't the greatest thing since sliced bread, nor will it take over the world, but it does fill a niche that some people find useful (and I still think comparing it to a laundry list of the mainstream languages is missing the point). Based on your post, your answer to the question "how would you solve problem X" seems to be "I wouldn't, I would avoid it in the first place". Which sounds great in theory (or if you have a time machine), but idealism doesn't meet deadlines very well.

      --
      ClutterMe.com - easiest site creation on the Net. Just click and type.
    21. Re:Lets invent yet another language! by puppetman · · Score: 1

      Sorry, you are wrong about BeanShell:

      From the wiki:

      Question: Does BeanShell reparse scripted methods on each invocation?
      Answer: No. Scripted methods are parsed once and stored in a parse tree. Reparsing can be forced by calling the source command.

      Question: Can I compile my beanshell scripts?
      Answer: There is currently no full bytecode compiler for BeanShell scripts, although one may exist in the future. In the mean time, there are ways to compile BeanShell scripts to Java classes that use the interpreter at runtime and also ways to get BeanShell to pre-parse scripted methods for performance.

      The are parsed, but not compiled to byte code, or run through a Just-In-Time compiler.

    22. Re:Lets invent yet another language! by @madeus · · Score: 1

      What I DON'T understand is dismissing Groovy outright because you have no use for it.

      In my defense, I'm not outright dismissing or attacking Groovy itself, I'm merely highly skeptical of the suppose benefits of the culture of 'lots of specialist niche languages/frameworks' as I personally feel the sheer number is more harmful than beneficial (certainly when teams decided implement particularly "niche" tools that their team happen to think are 'awesome', but that aren't widely known or supported).

      This is intended not to target Groovy specifically, which may or may not be able to reasonably justify it's existance, but with regard to the sort of approach to development common people who often so strongly evangelise tools like Groovy ('glue' for Java software is such as huge 'hot topic' among a lot of Java EE developers - primarily as a kludge to fix the undue verbosity it can entail, which is an issue when you are just trying to some fairly simple stuff).

      Which sounds great in theory (or if you have a time machine), but idealism doesn't meet deadlines very well.

      I do completely understand where you are coming from (and confess to not perhaps entirely always practicing what I might be regarded as preaching, here - at least not as much as I try to :-). As you rightly say, you do have to meet deadlines (even when that means building dumb solutions to make up for other peoples inadequacies[1]).

      As much as I like really do like Java, I've got to say (at the risk of repeating myself), if people didn't try and use it for what seems to be every single enterprise software project under the sun (no pun intended) their lives would be so much easier in the long run (and many things would get done faster, with less people - IMO). I don't think I have any sympathy when people make fundamentally bad decisions as serious as using entirely the wrong language, just because "it's popular" or "it's easier to get management on board with" (man is that one a huge risk area!).

      [1] While there is such a thing as 'victim of circumstance' at least 9 times out of 10 I'd say it's demonstrable outright ineptitude on someone's part. :-)

    23. Re:Lets invent yet another language! by angel'o'sphere · · Score: 1

      Oh,

      thats interesting, strange that I use BeanShell since 4 years or more and never saw this. I check next days.

      The source of the compiler and especially the code generator contains lots of byte code generating classes ... for what are those god for then, strange indeed.

      angel'o'sphere

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    24. Re:Lets invent yet another language! by angel'o'sphere · · Score: 1

      I checked again.

      The wiki is wrong. BeanShell uses this library: http://asm.objectweb.org/ to create byte code.

      angel'o'sphere

      --
      Cost free eBook I read (by iBook/Kobo/Amazon/ObookO/Gutenberg etc.): "The Green Odyssey" by Philip Jose Farmer.
    25. Re:Lets invent yet another language! by puppetman · · Score: 1


      I think you're mis-interpreting what ASM is being used for:

      From the URL you posted:

      "ASM is a Java bytecode manipulation framework. It can be used to dynamically generate stub classes or other proxy classes, directly in binary form, or to dynamically modify classes at load time, i.e., just before they are loaded into the Java Virtual Machine."

      I believe BeanShell makes some dummy stubs that are then dynamically modified at run time to the contents of the BeanShell script. Thus ASM. I found a reference to this once, but I can't locate it now.

  13. That's where Jython comes into play by Anonymous Coward · · Score: 0
    Why not learn a scripting language that could really benefit you? Python can run within the Jython environment on your JVM, interact directly with Java, yet is still written directly in Python syntax that can easily integrated within a distributed programming environment.

    Jython is an implementation of the high-level, dynamic, object-oriented language Python seamlessly integrated with the Java platform. The predecessor to Jython, JPython, is certified as 100% Pure Java. Jython is freely available for both commercial and non-commercial use and is distributed with source code. Jython is complementary to Java and is especially suited for the following tasks:

    • Embedded scripting - Java programmers can add the Jython libraries to their system to allow end users to write simple or complicated scripts that add functionality to the application.
    • nteractive experimentation - Jython provides an interactive interpreter that can be used to interact with Java packages or with running Java applications. This allows programmers to experiment and debug any Java system using Jython.
    • Rapid application development - Python programs are typically 2-10X shorter than the equivalent Java program. This translates directly to increased programmer productivity. The seamless interaction between Python and Java allows developers to freely mix the two languages both during development and in shipping products.

  14. Is Groovy a buzzword container class? by EmbeddedJanitor · · Score: 1
    "Groovy is ... agile dynamic web applications shell scripts test cases integration prototyping industrial strength applications"

    Hmmm, I wonder if it could be useful for teaching robotics on Lejos http://lejos.sourceforge.net/ ?

    --
    Engineering is the art of compromise.
  15. Weird title by Null+Perception · · Score: 1

    Why does this sound more like a porno flick than a scripting guide..

    --
    Great new book on Evolution: The Greatest Show on Earth by Richard Dawkins
  16. Objectivity and professionalism by ENOENT · · Score: 0, Flamebait

    You must be new here.

    --
    That's "Mr. Soulless Automaton" to you, Bub.
  17. Groovy Mondad by Bellum+Aeternus · · Score: 0, Flamebait

    So Goovy is like Mondad, I mean PowerShell, I mean PERL ripoff for Windows but not M$'s proprietary system? Groovy, I'll have to try that out.

    Could somebody in the know let me know if Groovy has the flexibility of PowerShell? Thanks in advance.

    --
    - I voted for Nintendo and against Bush
    1. Re:Groovy Mondad by Anonymous Coward · · Score: 0

      Yep, if we have PowerShell, we should just stop using or building other tools. I have used Groovy, and it is a step in the right direction.

      I guess the biggest plus for Groovy as opposed to Ruby (I am using Ruby right now on a project) is all the Java libraries that we can have direct access to from Groovy.

    2. Re:Groovy Mondad by Bellum+Aeternus · · Score: 1

      How did I get marked down as flame bait? Thanks for the responses, honestly I wanted to know if I could use Groovy to script the very few things that I need to because I'm not allowed to install PERL on this Win2k3 box.

      --
      - I voted for Nintendo and against Bush
  18. Whatever happened to.... by Anonymous Coward · · Score: 0

    Bean Shell? Dynamic Java? How is this language going to be easier to learn for Java developers than the other 2? And if I have to do some learning why not just learn Python and use Jython?

    1. Re:Whatever happened to.... by jkauzlar · · Score: 1

      Here's how I understand it: BeanShell was created as a 'command-line Java' useful in debugging purposes but pointless for actual development. Probably the same case is true for whatever Dynamic Java is. JPython is great, but you can't call JPython from Java, only the other way around. You'd naturally prefer to be able to call the scripting language from Java, because Java is a great language for defining the structure of a program and tedious for most coding.

      I believe, but am not certain, that Groovy solves these problems. That is, you can call it from Java. I should hope that it also allows first-class functions and other niceties found in dynamic languages.

    2. Re:Whatever happened to.... by Anonymous Coward · · Score: 0

      Groovy and Java code can call each other. Groovy can be used in script mode or compiled to a .class file. For deployment, it's like any other Java app with the addition of a groovy jar file. The integration with Java is what separates it from other scripting languages.

      The value of Groovy is mostly for Java developers. Dynamic typing, closures, dynamic code evaluation, generated getters/setters and other goodies not included with stock Java. Like other scripting languages, it contains powerful constructs to do more with less code.

      I've read most of the book. Actually, it's quite good as programming books go.

      Check out some of the examples. http://groovy.codehaus.org/

    3. Re:Whatever happened to.... by Anonymous Coward · · Score: 0

      you can call jython from java

    4. Re:Whatever happened to.... by Anonymous Coward · · Score: 0

      BeanShell works just fine as the macro language for jEdit.

    5. Re:Whatever happened to.... by Anonymous Coward · · Score: 0

      not very easily

  19. MOD PARENT UP! by Anonymous Coward · · Score: 0

    -1? C'mon, folks. I, for one, thought it was hilarious!

  20. Reminds me of that other book by Bitmanhome · · Score: 3, Funny

    Ironically, "Groovy Inaction" is the canonical book on accomplishing nothing at all.

    --
    Not that this wasn't entirely predictable.
  21. Back in the old days? by Jekler · · Score: 5, Funny

    Interesting how 2005 is now being referred to as "the old days" and 13 months is referred to as "an eternity". Personally I would've gone with "not too long ago" or "just before last year's taxes were due."

    Sorry, I've gained a bit of perspective. I wrote the preceding paragraph back in the golden days of typing, in the age prior to taking a sip of my Mt. Dew, but I'm no longer posting in the same world it was back then.

  22. Pun Understood by organgtool · · Score: 1

    You could say that I was a late developer (pun intended).
    Are you suggesting that you program from beyond the grave? You, my friend, are the Tupac of software developers.
  23. Re:Disco Duck... by mikelieman · · Score: 1

    Walt Disney? I'm sure you mean Rick Dees.

    --
    Technology -- No Place For Wimps! Grateful Dead and Jerry Garcia Chatroom -- http://www.wemissjerry.org
  24. Now you've done it... by ErichTheWebGuy · · Score: 1

    Anyone? Noone? OK, fine, I'll throw it out there, but I know you're all thinking it! :)

    Groovy in Action Always, or GinAA.

    --
    bash: rtfm: command not found
  25. Slashvertizing in Action by jb523 · · Score: 3, Funny

    Summary:
      * Groovy is in Java, and therefore current and former Java programmers will love it (wtf?)
      * Groovy is a dynamic language and therefore attractive to people who work in scripting languages (wtf?)
      * Grails is implemented using Groovy and therefore Ruby on Rails programmers will be interested.
      * Groovy is awesome!
      * This book is awesome!

    I've seen a lot of advertising masquerading as book reviews on slashdot, and I don't generally mind 'em too much, but this one's over the top. The author seems to think that the book will appeal to every group of people that could possibly be touched by some aspect of Groovy, and gives very odd reasoning for each case. The review imparts almost no information beyond that and a summary of the table of contents. If the book is half as proselytistic as this review, then it's unlikely to be worth the paper it's printed on. Then again, you shouldn't judge a book by its review.

    My favorite sentence is:
    "I like the approach of including guidance for using the language after you've learned it, because it acknowledges that the purpose of learning a programming language is to then use it."

    1. Re:Slashvertizing in Action by Ikari+Gendo · · Score: 2, Insightful
      This type of aggrandizement and posturing is typical of the Groovy community. See a recently derailed EclipseZone thread. Some sample Groovy-speak:

      Groovy is unique in its ability to integrate with Java at the syntax, object model and API level.

      Vague platitudes and drivel. Meanwhile they can't even get a simple definition of "closure" right, to say nothing of a parser that doesn't make Perl's interpreter look like a Scheme reference implementation.
    2. Re:Slashvertizing in Action by kaffiene · · Score: 1

      This type of aggrandizement and posturing is typical of the Groovy community. See a recently derailed EclipseZone thread. Some sample Groovy-speak:

      Groovy is unique in its ability to integrate with Java at the syntax, object model and API level.
      Vague platitudes and drivel. Meanwhile they can't even get a simple definition of "closure" right, to say nothing of a parser that doesn't make Perl's interpreter look like a Scheme reference implementation.

      uh, maybe you're just a bit slow then, because that sentance made perfect sense. It's saying that Groovy has similar syntax to java, uses the same APIs and shares the same object model within the JVM.

      What part of that was confusing to you? Not only was that perfectly clear, it was also quite relevant to Java programmers (and no, I don't use Groovy at all)
    3. Re:Slashvertizing in Action by Ikari+Gendo · · Score: 1

      Mostly the fact that it's a lie? Javascript Rhino has been around for quite some time, to say nothing of BeanShell et al.

    4. Re:Slashvertizing in Action by kaffiene · · Score: 1

      Uh... no.

      Java classes are second class citizens in Javascript and Groovy is compilable unlike Beanshell (the bit about the same object model as Java), so they have a point.

    5. Re:Slashvertizing in Action by Ikari+Gendo · · Score: 1

      Fine then. Scala compiles to Java, as does Kawa and Jython. The point is they claim "uniqueness," when it is not unique in any way except their own hype.

    6. Re:Slashvertizing in Action by kaffiene · · Score: 1

      ...and none of those languages is syntactically like Java

    7. Re:Slashvertizing in Action by Ikari+Gendo · · Score: 1

      Groovy is no more like Java than are Scala and Jython. Of course you already admitted that you don't know Groovy, and hence don't know this.

  26. a scripting language that targets the java vm !? by bcrowell · · Score: 2, Interesting

    To me, the java vm seems like the natural choice for a gigantic, mission-critical, server-side application that you start once and then allow to run without restarting for a long time. I don't understand why you'd want a scripting language that targets the java vm. Starting up the vm, and loading all its libraries, takes time, and for a typical application of a scripting language, that time could easily be an order of magnitude more than the time it should take for the code to run. Also, you don't get the benefit of JIT compilation if it's just a script that runs, does a job, and exits. Of course I realize that scripting languages aren't just for the kind of thing that unix shell scripts can do, but really, that's a major part of a scripting language's natural niche. Also, part of the Unix Way is that you write lots of small tools that work together; but if each of those tools is starting up a java vm, and then maybe invoking ten other tools that start their vms, it just sounds like a recipe for horrible performance.

    I haven't used rails, and don't know anything about grails, but I assume that a rails or grails application runs as a cgi, with a new process starting every time a user does something in a web interface. As a user of web interfaces, the last thing on earth I want is a web interface that has to start up a java vm every time I click on a button to submit a form. As a webmaster, I also can't see that as a good use of server-side resources. Or is there some mechanism similar to mod_perl that allows you to avoid this overhead?

    OK, correct me if I'm way off base, here!

  27. Re:Disco Duck... by Anonymous Coward · · Score: 0

    Rick Dees Nuts!

  28. Dating by lseltzer · · Score: 1

    'Groovy' is a 60's word. By the 70's it was only used in Archie comics

  29. Re:a scripting language that targets the java vm ! by fizzup · · Score: 4, Interesting

    Embed Groovy in your Java application to provide scripting extensions, and call the methods from inside your Java code.

  30. Java? by tuxlove · · Score: 1

    Let's see, runs under Java virtual machine, uses Java libraries and objects... Wouldn't that make it, um, Java?

    1. Re:Java? by Tupper · · Score: 1
      The Java libraries are large and useful. The JVM is widely deployed, reasonably fast, cross platform and garbage collected. These traits make the JVM a good platform.

      Java, the language, succedes as is a better C++ (for most purposes); but it still has large downsides. It's not duck typed and it doesn't have a class inference system. It's verbose; so people write tools to write Java, but the language makes that harder than it should be. Still, you end up with a lot of code generated (by the IDE or whatnot)--- Foo foo; getFoo() & setFoo are standard(!) and that is just the beginning. This generated code is inconvenient and adds no value. Its possible to do higher order programing in Java, but not natural.

      Other languages are more powerful...but the lack of good library support has left them at best as niche tools or academic toys. Implementing in the JVM (or CLR) solves that problem. Also, lots of existing code is in these environments, and the JVM based languages typically interact well with these programs.

      Groovy is one of these; kind of a Ruby in the JVM. Scala is even better, I think: Ruby meets Haskell in the JVM.

    2. Re:Java? by tuxlove · · Score: 1

      I.e, it's a high level language implemented as a Java application?

    3. Re:Java? by Tupper · · Score: 1
      Java is two distinct things: 1) a language and 2) a runtime.

      The Java language is ok, but not great.

      The Java runtime is somewhat better: the JVM is faster than most and the libraries are extensive.

      The Scala (or Groovy or Beanshell) compiler is a .jar (a Java application in sense 2) that reads .scala files and creates .class files. Those class files are Java applications (again in sense 2).

      All these languages can also be interpreted. Other languages-- notably variants of ruby, python, scheme and common lisp--- also use the java runtime.

    4. Re:Java? by tuxlove · · Score: 1

      Sorry, I was admittedly trolling here ever so slightly. I'm not a huge fan of Java or its VM.

  31. Re:a scripting language that targets the java vm ! by WWWWolf · · Score: 1

    I don't understand why you'd want a scripting language that targets the java vm.

    Why? To run those tiny scripts from your giant business app or a heavyweight desktop app once it's all started up...

    JDK 6 even includes a new extensible scripting framework support just for this very purpose, and ships with the Rhino JavaScript engine...

  32. Re:a scripting language that targets the java vm ! by bcrowell · · Score: 1

    Embed Groovy in your Java application to provide scripting extensions, and call the methods from inside your Java code.
    OK, seems logical. Are a lot of people actually using it for that? The review mentions "calling Groovy from a command-line," "writing automation scripts," and Grails for web applications. It doesn't mention the idea of using it as an extension language for java.

  33. no, not really by idlake · · Score: 2, Informative

    So Goovy is like Mondad, I mean PowerShell

    No, PowerShell is a shell, as the name suggests, and is based on the CLR. Groovy is a compiled language for the JVM.

    I mean PERL ripoff for Windows but not M$'s proprietary system?

    Well, no, Perl is a weakly-typed scripting language.

    I'm sorry programming languages are a blur for you, but there are big differences between them. Groovy is a god-sent for the Java platform, given what an awful language Java has turned into. Personally, I have no use for either Perl or PowerShell, and I think both of them have serious problems.

    1. Re:no, not really by Linux_ho · · Score: 1

      Personally, I have no use for either Perl or PowerShell, and I think both of them have serious problems.

      For particular applications, yes. Perl's a poor choice for writing an OS kernel, and Java's not a great choice for a simple command-line text processing tool. Both Java and Perl are good for web development, though it's easier to find web developers familiar with Java. No language is a perfect fit for every job. For many applications, Perl is a great tool.

      In a nutshell: use the right tool for the job.

      --
      include $sig;
      1;
    2. Re:no, not really by oohshiny · · Score: 1

      No language is a perfect fit for every job

      That's true but not relevant. What I'm saying is that for every software development job, there is a language that's better than Perl. Perl had a good run and it was far better than shell+awk, which it replaced, but by now, it's obsolete and there are better tools. The only thing that keeps the language going is inertia and a few libraries that haven't been ported to other languages.

      I mean, come on, look at the "upcoming" release. Is anybody waiting with bated breath for Perl 6? Is it even being used in any significant numbers?

  34. it's not a scripting language by idlake · · Score: 1

    Groovy was designed as a dynamically typed language that is compiled into the Java VM. Examples of scripting languages based on the Java VM are Beanshell, Jython, and JRuby. In terms of language features, the two kinds of languages may seem fairly similar, but Groovy should perform better than the scripting languages.

    1. Re:it's not a scripting language by mandelbr0t · · Score: 1

      You'd think it would, but my experience says otherwise. Groovy to this point has concentrated on loose data-typing and syntactic sugar that make it conducive to scripting. The fact that it can directly instantiate Java classes in its classpath really makes it a powerful choice for administration scripts that run on your existing J2EE infrastructure. However, it lacks:

      1) Good debugging support, at least as of a few months ago. I still need to println all my debugging, and I can't trace into the Groovy source code to track down bugs (yes, I've found a couple of those too, but I can't prove it due to the lack of a debugger. Looks like a hash collision in the Groovy.Sql stuff)

      2) strict typing. Unfortunately, the loose-data typing is a double-edged sword. It's great if you just want to hack together a script in 10 minutes, but it's terrible for trying to lexically bind variables to a particular closure or class. A Perl-like 'use strict' (with all the suboptions) is badly needed. Combine this one with 1) and you've got a nightmare trying to write a large application with Groovy alone.

      Finally, GRAILS is horrible. Ostensibly a RAD web development platform, it doesn't even cache the java byte-code so each page refresh on the simplest database application takes ~2 seconds on a modern PC. Not very rapid, IMO.

      So, I'd say that Groovy is still very much a scripting language, and will remain that way. Use Java for the big stuff and call it from Groovy.

      --
      "Please describe the scientific nature of the 'whammy'" - Agent Scully
  35. Re:a scripting language that targets the java vm ! by pkulak · · Score: 1

    Well, it's a "scripting language", but it won't get started and stopped on every request like a Perl script in 1995. Groovy compiles to Java ByteCode, so the application server doesn't know you were naughty and didn't use a completely statically typed language.

  36. Re:a scripting language that targets the java vm ! by deander2 · · Score: 1

    but I assume that a rails or grails application runs as a cgi, with a new process starting every time a user does something in a web interface.

    yeah, this assumption is quite wrong. i don't know of *any* even remotely popular language targeting web apps that does this. (django, ruby, java, php, .net, you name it) this was proven not to scale over a decade ago. :)

  37. Addendum by @madeus · · Score: 1

    Addendum: I would probably turn round and hassle the other people (be they internal, customers or vendors) to fix their broken system or write a specific class/classes in Java to fix the problem (e.g. load a specific class to extend the primary class to unmangle things) to try and keep the logic in one place (and also because I'm a huge fan of 'get other people to write non broken systems' approach, of course they always do, but that doesn't discourage me any in trying to get rid of it when I see it, I'm often a huge PITA in that respect - not that I mind working round things, but I like to make it clear when someone else has done something stupid and can't/won't fix it :-).

    Your example actually reminds me of a similar example someone gave here recently (also a Java developer, who must have been using something very similar to Groovy, if not in fact Groovy itself). So while it's probably not something I would do, I wouldn't say 'never' (I can see the benefit, certainly if you can keep control of it and don't have wacky developers doing dubious things with it down the line :-).

    1. Re:Addendum by Anonymous Coward · · Score: 0

      Yeah I know what you mean. It sucks that we frequently have to let the idiots have their day. In this case, it made more sense to remove the records and resend them for a couple reasons: first of all, these are production machines, so we dont want to have to deploy any code unless absolutely necessary (think 24/7 high availability), and secondly, because we want to keep the data in a clean state for future developers. Anyway, the script was no big deal, and I didnt have to do a week's worth of testing on it.
      (god I wish I had a better job)

  38. JVM targeted languages reviewed comprehensively by tezza · · Score: 2, Informative
    JVM Language Soko-Shootout includes a section on Groovy. Steve was not very impressed.

    He liked the NICE language the best.

    --
    [% slash_sig_val.text %]
    1. Re:JVM targeted languages reviewed comprehensively by Anonymous Coward · · Score: 0

      This review is very, very VERY old... groovy was in very pre releases, and after that, a drastical change was made.

  39. Re:Dating - Hey, it's the 60's by Nom+du+Keyboard · · Score: 1
    Groovy' is a 60's word.

    Second that. So he's even later than he thinks.

    --
    "It's the height of ridiculousness to say for those 9 lines you get hundreds of millions."
  40. please get your terminology straight... by Anonymous Coward · · Score: 0

    Groovy to this point has concentrated on loose data-typing

    Languages are classified into strong/weakly typed, and statically/dynamically typed.

    strongly typed: Java, Groovy, Python, Eiffel, Lisp
    weakly typed: Perl, Tcl, assembler

    statically typed: C, Java, Eiffel
    dynamically typed: Groovy, Python, Perl, Lisp

    Scripting languages are usually dynamically typed, but not all dynamically typed languages are scripting languages. And many dynamically typed languages are strongly typed.

  41. Re:a scripting language that targets the java vm ! by Anonymous Coward · · Score: 0

    You mean that was proven back in the day when a significant percentage of CPU cycles were needed to fork a process?

    Today I bet it's absolutely a non-issue, and huge layers upon layers of frameworks are likely a much higher burden on both the machine and the developer. (This is not saying that all frameworks, or Java are bad, or that you should do everything CGI. Definitely not. And there's also FastCGI; same idea, but more efficient.)

  42. one more thing by Anonymous Coward · · Score: 0

    If dynamic typing really bothers you, you aren't writing unit tests.

  43. Itself is Immutable by fm6 · · Score: 1
    You're reading "capitalize itself" out of context. "Know how" refers to the logic that's built into the object — nonstatic methods. For example, a Java string knows how to convert itself to upper case:

    String s1 = "hello";
    String s2 = s1.toUpperCase(); //s2 == "HELLO"
    AC is just saying that there should also be a nonstatic method .toCapitalized() that would just force the first character ("Hello"). Nothing to do with immutability.

    1. Re:Itself is Immutable by Zeek40 · · Score: 1

      Are you saying that the .toCapitalized() method would change the string itself from ("hello") to ("Hello") or it would return a new string? I mean would the method be declared public void toCapitalized() or public String toCapitalized() ? I was assuming that he wanted the former, which is impossible with an immutable string. The latter trivial would be trivial to implement as a utility method and has little to do with the underlying design decision to make strings immutable, which is why i assumed that the AC was focusing his complaints on the actual class design, rather than the utility methods associated with it. It's silly to complain about a lack of a utility function, they're easy to implement and no class is going to have every single one that you want. Where's my public String toLeet() to change ("hello") into ("h3LL0")? Complaining about overall design makes more sense, that's why I was focusing on that.

    2. Re:Itself is Immutable by fm6 · · Score: 1

      Dude, I said that .toCapitalized was like the existing .toUpperCase. If you'd go and read the docs for the API, you could answer your own questions, instead of wasting both our time.

  44. Could Groovy replace Java? Some features cryptic by obiwan2u · · Score: 2, Interesting
    For reasons described above, I don't think Groovy will replace Perl anytime soon, but it might make a great teaching language. You can start out very simply and expand into GUI programming, web programming, and any of the other million Java library functions that exist.

    In fact, it might make a great replacement for Java. Features that really should've been there from the beginning are no easy to access (ranges, easy to use lists & associative arrays, reasonable string handling)

    Although you can start out simply in Groovy, I find some of the funky "iterator attributes calling code snippets declared in 'closures' " to be cryptic. Here's an example (basically from listing 7.23 of the Groovy in Action book, see http://www.benslade.com/projects/java/groovy/Listi ng_7_23_GPath.groovySelfDoc.html for the full example):

    assert ['ULC'] ==
    invoices.objLineItemList.grep{ aLineItem -> aLineItem.totalCostLineItem() > 7000}.product.name

    I think this says:

    1. for the invoices list of invoice objects
    2. for the attribute of the invoice consisting of a list of line items
    3. for each invoice, for each line item in the list, search via "grep" (although it's not using regex's here)
    4. pass the line item into the {}'s via the "aLineItem" parameter (the "->" is the delimeter, weird)
    5. calculate the total cost of the line item via it's totalCostLineItem method
    6. if it matches the greater than condition then, take the name attribute of product attribute of the current line item and return it as a list to be tested by the assert statement.

    I'm just starting out so maybe it'll start to make sense to me later, but Groovy's more advanced features are definitely not for beginners or simple scripting applications.

    Ben Slade
    Chevy Chase, MD

    --
    Ben in DC
    "It's the mark of an educated mind to be moved by statistics" Oscar Wilde
  45. Well, it's prolly not that bad. by typicallyterrific · · Score: 1

    Here's the interesting thing: it does not really matter anymore, if all we care about are other interpreted, programmer-friendly scripting languages.

    If we're concerned about using this against Perl, Python, PHP, Smalltalk or Ruby, using the great language shooutout benchmark*, Java is about on par, if not better overall based on CPU time alone.

    My understanding of the jvm, which may be flawed, is that it first interprets the bytecode and eventually gets around to compiling it into native machine code - meaning that over the life time of large apps it has a negligible performance hit. So, in theory, Java can only ever be, at worst, as slow as any other interpreted language.

    This is something we've come to accept; linux installers are built on python, large websites on ruby and we constantly call perl scripts from our command lines. It's not really that terrible as for the majority of apps these languages are fast enough.

    The same should apply to groovy. It also seems that groovy is intended for current Java devs for quick prototyping, so it's not like they don't have to load the jvm constantly anyways.

    Finally, as far web apps are concerned, I know for a fact that Java is used all over the place in companies for stuff like that, and that it's a popular backend language. I can only imagine that all of these apps find *someway* of keeping the JVM alive long enough to get that amortized reduced performance cost. It'd just be silly not to.

    *disregarding, of course, all of the obvious problems with using that benchmark. We're doing back of the envelop stuff here, nothing too serious.

  46. My beef with Groovy by feijai · · Score: 4, Interesting

    I believe firmly that new language should appear in the world butt-naked beautiful. Elegant, consistent, and with a good formal footing. They grow warts as they age, though some (like Lisp) have managed the wart stage with much more elegance than others (like C++).

    Here's the thing. As I've watched it, Groovy has appeared on the scene as a big giant hack. It's got a piecemeal formalism: it was clearly conceived originally by people who do *not* know how to make programming languages, and then as it somehow squirmed its way into a JSR it gathered the interest of people who *do* know what good languages looke like, and they tried hard to clean it up, but not entirely. And it's got HUGE numbers of ugly inconsistencies, compounded by a need to be approximately backward-compatable with Java for no particularly good reason (interoperability and sermantic compatability != syntactic compatability).

    And... it's slow. That's a big deal. Take kawa, for example, the leading Scheme system written in Java. Kawa has optional type declarations, and with them added in, it's about 1.5 times slower than Java. Without them, it's 10-40 times slower, more or less like Groovy. The point is that kawa, a language *totally* *alien* to Java semantics, is decently fast. Groovy, a language which is attempting to be a superset of Java, more or less, is *not* decently fast. It's not like you can't _make_ a fast Java language. Kawa did it. Groovy's a mess.

    There's my rant.

  47. Re:a scripting language that targets the java vm ! by msgilligan · · Score: 1
    You can package a Grails app as a WAR using the

    grails war command. The WAR can then be deployed to a servlet container (such as Tomcat) or a JEE server (such as JBoss). Ruby on Rails also supports several mechanisms to avoid per-request startup overhead. (The JRuby people are working on deploying Rails apps as WARs...)

    I have tried using Groovy for command line utilities and JVM performance has, in fact, been an issue. There are ways such as Nailgun for elminating JVM startup overhead, but Groovy (last I checked) doesn't provide an "out of box" solution.

  48. Re:a scripting language that targets the java vm ! by jilles · · Score: 1

    1) Basically any server application needs to run all the time.
    2) Starting the vm on a modern machine takes about 0.5 seconds.
    3) Loading a few MB worth of libraries of course takes time; in any language. J2ee servers are indeed huge. But then they also include a lot of functionality and actually most of the time it spends booting it is actually executing functionality rather than loading libraries.
    4) Groovy is compiled to bytecode. That means it is being JIT compiled. Which makes perfect sense in a server environment. Since the JVM has mechanisms for dynamically loading and unloading classes, that does not conflict with the dynamic nature of a language like groovy.
    5) Scripting is about more than the unix shell, although ant+groovy is a very useful addition to that toolset.
    6) Serverside groovy doesn't work like cgi scripts (well it could but only a retard would use it like that). It merely builds on one of the early innovations over cgi to not kill the process in between requests. This has been commonly used in the servlet APIs since about 1998 and most apache modules now do something similar (e.g. php). Building on the J2ee architecture gives a few scalability benefits to groovy that most other scripting just lack.
    7) If you are a webmaster, you should know all of the above.

    And yes, you were way off base. Basically all the assumptions you made are plain wrong.

    --

    Jilles
  49. Re:a scripting language that targets the java vm ! by slamb · · Score: 1

    [A new process starting every time a user does something in a web interface] was proven not to scale over a decade ago.
    You mean that was proven back in the day when a significant percentage of CPU cycles were needed to fork a process? Today I bet it's absolutely a non-issue, and huge layers upon layers of frameworks are likely a much higher burden on both the machine and the developer. (This is not saying that all frameworks, or Java are bad, or that you should do everything CGI. Definitely not. And there's also FastCGI; same idea, but more efficient.)

    It sounds like you think these two things (forking a CGI on every hit and using a lot of abstraction layers) have independently computable performance impacts. If you indeed believe that, you're dead wrong - the performance penalty of the abstraction layers is largely paid on startup, so it's negligible in a long-lived process FastCGI, and horrible in a process-per-hit like CGI. In other words, if you measured these four quantities:

    • A: CPU time/hit for FastCGI script with no framework
    • B: CPU time/hit for FastCGI script with framework
    • C: CPU time/hit for CGI script with no framework
    • D: CPU time/hit for CGI script with framework

    You'd find that (D - C) >>> (is much greater than) (B - A). Also that C >>> B. The comparison between A and B will be much closer, and can really go either way.

    Why, you ask? fork() is comparatively cheap, yes. That's never been why CGI is horribly expensive. The real cost begins with execv("/usr/bin/perl", ...), continues with loading all those modules, and finishes with creating a new RDBMS connection and requerying any otherwise-cacheable state. You seem to be saying "you need to reduce the number of modules to make it fast", but the real answer is make all of those costs 0 - don't redo that work on every request. This is the solution people came up with 10 years ago, and it's more valid now than it ever has been. Those layers of abstraction serve a purpose - they make it much easier to write large systems, and often they provide performance benefits through easy-to-use pooling and caching.

    Consequence: A mod_(perl|python|php|ruby), FastCGI, or servlet engine-based system, with or without all those modern layers of abstraction, will mop the floor with a Perl CGI every time. If you doubt that, don't make silly bets on slashdot - just do the benchmark.

  50. Re:Could Groovy replace Java? Some features crypti by Fweeky · · Score: 1
    I've never used Groovy, but it looks fairly clear to me (though I have a Ruby background), except the final bit looks like it should be *.product.name (which will apply .product.name to each element of the list to the left of the operator):
    1. send objLineItemList to invoices (returns a List)
    2. send grep to the List with a closure (returns a List containing each element for which closure(element) returns true)
    3. for each element of the List, send product, and to the return value of that send name (returns a list with the result of that for each element, equivilent to list.map { item -> item.product.list})
    4. send == to the List literal ['UCL'] with the mapped list as an argument, (returns a boolean)
    5. send that to assert which will do something if it's false

    Here's the rough equivilent in PHP:

    assert(array('UCL') == array_map(array_filter($invoices->objLineItemList( ), create_function('$aLineItem', 'aLineItem->totalCostLineItem() > 7000'))), create_function('$aLineItem', '$aLineItem->product()->name()'));
    Or in less dense form:

    $ExpensiveItems = array();
    foreach ($invoices->objLineItemList() AS $aLineItem)
    {
        if ($aLineItem->totalCostLineItem() > 7000)
        { // you could of course do the code in the loop below here
            $ExpensiveItems[] = $aLineItem;
        }
    }
    $ExpensiveItemNames = array();
    foreach ($ExpensiveItems AS $aLineItem)
    {
        $ExpensiveItemNames[] = $aLineItem->product()->name();
    }
    assert(array('UCL') == $ExpensiveItemNames);
  51. Re:Could Groovy replace Java? Some features crypti by Fweeky · · Score: 1

    Oops, add return(..) around the create_function bodies; no implicit return values in PHP.

  52. Re:Disco Duck... by __aaclcg7560 · · Score: 0

    I'm referring to the Walt Disney version of the song. I wasn't aware that someone else wrote it.

  53. Multi Core / Multiple CPU performance by @madeus · · Score: 1

    With all the new cores/gpus available and programming getting complex everyday, we do need much more optimized and easier to use languages.

    I am a huge fan of easier to use (and more specifically, maintain), and more 'automatically optimized' languages.

    I think Java's syntax (copied by everything from C# & VB.NET and PHP - you write eerily identical code in all four now) is actually pretty great, that doesn't much to do with the efficiency of the implementations though (when it comes to multi core systems). Sun's gcc-workalike C compiler is great for building software target to systems like T2000's, and making use of threads in things like Perl is fairly trivial (let alone something like Ruby) - it's not as if it's significantly easier in Java. In the case of web services apps (particularly with scripting languages), the web server (typically Apache) does much of the work too (at least, if you have designed your software appropriately!).

    I don't know that Groovy has anything special to offer in this regard, again I don't see what it has over existing tools in respect to the issues you've raised. For the most part I expect many (not all, but a significant number at the very least) won't even really have a proper awareness of other ways they could be working or other established tools they could be using (frankly, I think because they are not engaged much in the field they have chosen to specialize in, and because most higher educational establishments - where most of them learned how to be code monkeys - don't bother to explore as part of a wider and more rounded curriculum).

    All they know is "Java is best thing to use right, because everybody uses it?" and "Sun T2000 must be awesome because it has loads of cores.". Managers also often come to similar conclusions. Same deal with the man-on-the-street and the PS3 really (for not quite identical, but very similar, reasons). In truth, the T2000's, much like the PS3's, are still going to get spanked pretty much every time by less exotic decent (x86/x64) multi core system. I think there are parallels there with approaches to software development too.

    In most real world enterprise scenarios an 8 CPU Sun Fire 4600 will spank a 32 CPU Sun Fire E20K. Forget the hype about 'cell processing' you might have read! Half the 'optimization' advice Sun give is around using different *zones* in multiple CPU systems (which is, basically, pointless and a rehash of the blade idea that has failed to catch on, because the cost of ownership isn't very good), and as I've said writing threaded/parallel software is nothing new. In by far the majority of cases, 16 fast (3.0 Ghz AMD) cores will beat 72 slower (crappy UltraSPARC) cores IME, and it's cheaper too.

    IMO, write your software to scale horizontally, beware of "new shiny" snake oil and you are some way to being on the right track. Google's systems are a good example in this respect. The enterprise level stuff that most of us are writing on a day to day basis is pretty straight froward to both write in an entirely scalable fashion, it's just that some people manage to make an almighty mess of it and then convince themselves what they are doing is in some way uniquely difficult.

    I had to laugh when I read some one having a go at games development programmer on a forum recently "What's the deal with you games programmers anyway? Why do you think what you are doing is so much harder than what other developers are doing?". I do not develop games for a living, but I have - and do - play around with games development for fun. It's several of orders of magnitude more difficult to do well. I just though "Man, these enterprise guys really have no idea how easy the work they are doing is.".