Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Groovy in Action

samzenpus posted more than 7 years ago | from the look-at-all-the-colors dept.

Book Reviews 154

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.

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.

cancel ×

154 comments

Sorry! There are no comments related to the filter you selected.

I'm outta troll material for now (0, Offtopic)

plastic.person (776892) | more than 7 years ago | (#18185522)

So instead I'll just say: hi slashdotters! :)

Re:I'm outta troll material for now (-1, Flamebait)

Anonymous Coward | more than 7 years ago | (#18185948)



Simon P. Chappell == self-important cock + delusional religious kook + slashdot troller + fuckhead

obvious (1)

User 956 (568564) | more than 7 years ago | (#18185540)

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?

Not obvious enough (3, Funny)

Bob Gelumph (715872) | more than 7 years ago | (#18185806)

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

Re:Not obvious enough (1)

User 956 (568564) | more than 7 years ago | (#18185874)

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)

Re:Not obvious enough (1)

Anpheus (908711) | more than 7 years ago | (#18186234)

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

Disco Duck... (0, Offtopic)

creimer (824291) | more than 7 years ago | (#18185544)

I missed the partying in the 70's and so was not exposed to the full groovy experience that was available.

Get a copy of Walt Disney's "Disco Duck", play it 100 times, and you're never want to listen disco music ever again.

Re:Disco Duck... (1)

mikelieman (35628) | more than 7 years ago | (#18186572)

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

Re:Disco Duck... (0)

Anonymous Coward | more than 7 years ago | (#18186686)

Rick Dees Nuts!

Ha ha ha. (1)

ReluctantBadger (550830) | more than 7 years ago | (#18185554)

"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."
Tosser.

Finally, Slashdot links to Amazon (1, Insightful)

Anonymous Coward | more than 7 years ago | (#18185578)

It's nice to see that Slashdot has finally started linking to the Amazon listing [amazon.com] 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.

Re:Finally, Slashdot links to Amazon (0, Troll)

Anonymous Coward | more than 7 years ago | (#18185940)

Can someone find and kill this goddamned asslicker?

Re:Finally, Slashdot links to Amazon (0)

Anonymous Coward | more than 7 years ago | (#18188060)

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.

Groovy Groovy (-1, Offtopic)

Anonymous Coward | more than 7 years ago | (#18185586)

Groovy groovy groovy, groovy Java. Groovy groovy groovy!
Groovy groovy? Groovitty groovit groovy; Groovy groovy.
Groovy groovy! Java groovy!
Groovie.

Biased reviewer, reads like an ad for Groovy (2, Informative)

Anonymous Coward | more than 7 years ago | (#18185612)

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

Is Groovy a buzzword container class? (1)

EmbeddedJanitor (597831) | more than 7 years ago | (#18186030)

"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/ [sourceforge.net] ?

Re:Biased reviewer, reads like an ad for Groovy (0)

Anonymous Coward | more than 7 years ago | (#18186060)

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.

Re:Biased reviewer, reads like an ad for Groovy (0)

Anonymous Coward | more than 7 years ago | (#18186606)

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.

Objectivity and professionalism (0, Flamebait)

ENOENT (25325) | more than 7 years ago | (#18186236)

You must be new here.

Re:Biased reviewer, reads like an ad for Groovy (0)

Anonymous Coward | more than 7 years ago | (#18186922)

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?

Re:Biased reviewer, reads like an ad for Groovy (0)

Anonymous Coward | more than 7 years ago | (#18187154)

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.

Re:Biased reviewer, reads like an ad for Groovy (0)

Anonymous Coward | more than 7 years ago | (#18188620)

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?

70s were crap (1)

Intron (870560) | more than 7 years ago | (#18185664)

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

Re:70s were crap (1)

nuzak (959558) | more than 7 years ago | (#18185872)

> 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.

Re:70s were crap (1)

Intron (870560) | more than 7 years ago | (#18186602)

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.

Re:70s were crap (1)

TheDreadSlashdotterD (966361) | more than 7 years ago | (#18187280)

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.

Re:70s were crap (1)

nuzak (959558) | more than 7 years ago | (#18187734)

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.

Re:70s were crap (1)

LuisAnaya (865769) | more than 7 years ago | (#18185952)

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.

Re:70s were crap (1, Informative)

Anonymous Coward | more than 7 years ago | (#18186070)

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

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

Re:70s were crap (0)

Anonymous Coward | more than 7 years ago | (#18187232)

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

Re:70s were crap (2, Informative)

nuzak (959558) | more than 7 years ago | (#18187760)

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.

Re:70s were crap (0)

Anonymous Coward | more than 7 years ago | (#18186460)

"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."

Re:70s were crap (0)

Anonymous Coward | more than 7 years ago | (#18186192)

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)...

Re:70s were crap (1)

blootooth (653423) | more than 7 years ago | (#18187480)

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

This is only slightly more interesting than... (5, Funny)

dotancohen (1015143) | more than 7 years ago | (#18185674)

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

MOD PARENT UP! (0)

Anonymous Coward | more than 7 years ago | (#18186268)

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

Re:This is only slightly more interesting than... (0, Redundant)

Frosty Piss (770223) | more than 7 years ago | (#18186320)

Funny! Mod up. Very funny!

obligatory bruce campbell (0)

flynt (248848) | more than 7 years ago | (#18185716)

Groovy. [impossiblefunky.com]

Trilobyte (1)

TheRealMindChild (743925) | more than 7 years ago | (#18185732)

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).

Re:Trilobyte (1)

Fez (468752) | more than 7 years ago | (#18186546)

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 [wikipedia.org] and http://en.wikipedia.org/wiki/The_11th_Hour_(comput er_game) [wikipedia.org]

Similarity To : (0)

Anonymous Coward | more than 7 years ago | (#18185754)


C#.

Comments welcome.

Looks like Ruby (0, Troll)

Anonymous Coward | more than 7 years ago | (#18185804)

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.

Re:Looks like Ruby (0)

Anonymous Coward | more than 7 years ago | (#18186018)

Damn...why do people use this again?

Re:Looks like Ruby (1)

charlesbakerharris (623282) | more than 7 years ago | (#18186024)

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

Re:Looks like Ruby (0)

Anonymous Coward | more than 7 years ago | (#18188440)

What the hell is streamlined about Java classes?

Re:Looks like Ruby (0)

Anonymous Coward | more than 7 years ago | (#18186246)

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.

Re:Looks like Ruby (0)

Anonymous Coward | more than 7 years ago | (#18186550)

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

Re:Looks like Ruby (1)

Zeek40 (1017978) | more than 7 years ago | (#18186522)

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 [sun.com] is the class that should implement the capatalize() function, but unfortunatley it's missing there too. =P

Re:Looks like Ruby (1)

crayz (1056) | more than 7 years ago | (#18186910)

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

Itself is Immutable (1)

fm6 (162816) | more than 7 years ago | (#18188562)

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.

Re:Looks like Ruby (1, Informative)

Anonymous Coward | more than 7 years ago | (#18187072)

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.

wow. (0)

Anonymous Coward | more than 7 years ago | (#18185832)

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!!!!"

Lets invent yet another language! (1, Troll)

@madeus (24818) | more than 7 years ago | (#18186010)

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)

Re:Lets invent yet another language! (0)

Anonymous Coward | more than 7 years ago | (#18186344)

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'.

Re:Lets invent yet another language! (0)

Anonymous Coward | more than 7 years ago | (#18186374)

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.

Re:Lets invent yet another language! (1)

junklight (183583) | more than 7 years ago | (#18186410)

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.

Re:Lets invent yet another language! (1)

@madeus (24818) | more than 7 years ago | (#18187534)

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.

Re:Lets invent yet another language! (0)

Anonymous Coward | more than 7 years ago | (#18186468)

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.

Re:Lets invent yet another language! (1)

@madeus (24818) | more than 7 years ago | (#18187614)


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! :-).

Addendum (1)

@madeus (24818) | more than 7 years ago | (#18187808)

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 :-).

Re:Addendum (0)

Anonymous Coward | more than 7 years ago | (#18187996)

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)

Re:Lets invent yet another language! (1)

arthurs_sidekick (41708) | more than 7 years ago | (#18186498)

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.

Re:Lets invent yet another language! (0)

Anonymous Coward | more than 7 years ago | (#18186706)

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

Re:Lets invent yet another language! (0)

Anonymous Coward | more than 7 years ago | (#18187112)

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

Re:Lets invent yet another language! (1)

@madeus (24818) | more than 7 years ago | (#18187668)

*snicker*

*hugs Java out of sympathy*

Re:Lets invent yet another language! (0)

Anonymous Coward | more than 7 years ago | (#18187912)

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.

Re:Lets invent yet another language! (2, Informative)

puppetman (131489) | more than 7 years ago | (#18186520)


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).

Re:Lets invent yet another language! (1)

erinol0 (698793) | more than 7 years ago | (#18186774)

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.

Re:Lets invent yet another language! (1)

ady1 (873490) | more than 7 years ago | (#18186612)

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

Re:Lets invent yet another language! (4, Informative)

Joey Vegetables (686525) | more than 7 years ago | (#18186640)

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.)

That's where Jython comes into play (0)

Anonymous Coward | more than 7 years ago | (#18186014)

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.

Weird title (1)

Null Perception (914562) | more than 7 years ago | (#18186152)

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

Groovy Mondad (0, Flamebait)

Bellum Aeternus (891584) | more than 7 years ago | (#18186254)

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.

Re:Groovy Mondad (0)

Anonymous Coward | more than 7 years ago | (#18186626)

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.

no, not really (2, Informative)

idlake (850372) | more than 7 years ago | (#18187646)

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.

Whatever happened to.... (0)

Anonymous Coward | more than 7 years ago | (#18186260)

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?

Reminds me of that other book (3, Funny)

Bitmanhome (254112) | more than 7 years ago | (#18186392)

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

Back in the old days? (5, Funny)

Jekler (626699) | more than 7 years ago | (#18186500)

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.

Pun Understood (1)

organgtool (966989) | more than 7 years ago | (#18186560)

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.

Now you've done it... (1)

ErichTheWebGuy (745925) | more than 7 years ago | (#18186604)

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

Groovy in Action Always, or GinAA.

Slashvertizing in Action (3, Funny)

jb523 (220004) | more than 7 years ago | (#18186618)

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."

Re:Slashvertizing in Action (2, Insightful)

Ikari Gendo (202183) | more than 7 years ago | (#18187914)

This type of aggrandizement and posturing is typical of the Groovy community. See a recently derailed EclipseZone thread [eclipsezone.com] . 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.

a scripting language that targets the java vm !? (2, Interesting)

bcrowell (177657) | more than 7 years ago | (#18186676)

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!

Re:a scripting language that targets the java vm ! (4, Interesting)

fizzup (788545) | more than 7 years ago | (#18186792)

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

Re:a scripting language that targets the java vm ! (1)

bcrowell (177657) | more than 7 years ago | (#18187596)

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.

Re:a scripting language that targets the java vm ! (1)

WWWWolf (2428) | more than 7 years ago | (#18187574)

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 [java.net] just for this very purpose, and ships with the Rhino JavaScript engine...

Re:a scripting language that targets the java vm ! (1)

pkulak (815640) | more than 7 years ago | (#18187756)

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.

Re:a scripting language that targets the java vm ! (1)

deander2 (26173) | more than 7 years ago | (#18187772)

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. :)

Re:a scripting language that targets the java vm ! (0)

Anonymous Coward | more than 7 years ago | (#18188326)

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.)

Dating (1)

lseltzer (311306) | more than 7 years ago | (#18186722)

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

Re:Dating - Hey, it's the 60's (1)

Nom du Keyboard (633989) | more than 7 years ago | (#18188040)

Groovy' is a 60's word.

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

Java? (1)

tuxlove (316502) | more than 7 years ago | (#18186942)

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

Re:Java? (1)

Tupper (1211) | more than 7 years ago | (#18187838)

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.

it's not a scripting language (1)

idlake (850372) | more than 7 years ago | (#18187706)

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.

Re:it's not a scripting language (1)

mandelbr0t (1015855) | more than 7 years ago | (#18187854)

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 get your terminology straight... (0)

Anonymous Coward | more than 7 years ago | (#18188120)

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.

one more thing (0)

Anonymous Coward | more than 7 years ago | (#18188388)

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

JVM targeted languages reviewed comprehensively (2, Informative)

tezza (539307) | more than 7 years ago | (#18187910)

JVM Language Soko-Shootout [cabochon.com] includes a section on Groovy [cabochon.com] . Steve was not very impressed.

He liked the NICE language [sourceforge.net] the best.

Re:JVM targeted languages reviewed comprehensively (0)

Anonymous Coward | more than 7 years ago | (#18188726)

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

Need an Account?

Forgot your password?

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>