Friday, March 03, 2006

Groovy: The Ed Burnette Effect

So as typically is the case when a few positive posts arise about Groovy, an alternative view point has cropped up entitled "BeanShell: groovier than Groovy" by Ed Burnette. The article quotes only the last paragraph of my previous post about how Groovy is approaching its "second" version 1.0, conveniently brushing over and failing to comment on any of the benefits highlighted.

Unfortunately, this is where many Java developers, with all due respect to Mr Burnette, fail to understand what a "dynamic" language is and its a shame this misunderstanding is being spread. I like BeanShell I appreciate what they are trying to do and in certain circumstances would recommend it over Groovy. It is great for embedding in Java applications if you want to script say an application server or or server component, but the fundamental difference is that BeanShell is a scripting language for the Java language, whilst Groovy is a "dynamic" language for the JVM (note the difference between Java the language and the JVM).

BeanShell is essentially Java without the need to specify types, which is great in certain circumstances, but doesn't really have much productivity gain and is not in my opinion the answer to the JVMs dynamic needs. I have written a lot of code in both BeanShell and Groovy and with Groovy my lines of code (LOC) count is about 60-70% less then the equivalent Java code, with BeanShell this is about 10%, as its essentially just Java without the need for type safety.

This is also why BeanShell has managed to achieve relative stability and a small size (as highlighted in Ed's article) when compared to Groovy as its goals are relatively simple. Groovy adds new language constructs, closures, the GDK methods, builders, meta-programming etc. This is not something you can achieve without spending a longer period of time defining the language and the API. Yes, following the standardisation process there was a re-think of many of the aspects, but this is the usual process with the JSR and any standard spec. Fortunately the syntax, through this process, has been nailed down and the Groovy development team are merely focusing on improving the core of Groovy.

6 comments:

Anonymous said...

Yes I've noticed the difference between Java the language and the JVM.

But could you elaborate more on what makes a language "a dynamic language for the JVM," and why Groovy is such a language and BeanShell is not.

Graeme Rocher said...

Well that requires a whole separate post in itself rather than confining it to a comment. I will post another article on my blog in the coming days on the differences between a scripting language and a dynamic language.

Anonymous said...

Have you seen http://www.cabochon.com/~stevey/sokoban/

To quote from http://www.cabochon.com/~stevey/sokoban/docs/article-groovy.html:

"Groovy's got so much wrong with it that you could almost write a textbook about it, with individual Badness Chapters, a Table of Badness, and a Bad Index."

"You are behind -- many languages (e.g. PNuts, Jython, Rhino) are way ahead of you in stability, usability, and adoption. And other serious contenders (notably JRuby, but also Nice and Java itself) are working at a furious pace. This is a crowded space, and marketing alone won't save you: when push comes to shove, people want a language that works. And Groovy's years away."

Graeme Rocher said...

Yes I have seen that article, but it is very old, and Groovy has come on a lot since then. It had many bugs at the time (that article was written pre-beta 8, mayh releases ago), and the documentation was (and still is) poor. Hence the developer never really understood how to implement certain things because he had no point of reference.

Groovy is maturing now, and the bugs are getting sorted out. And with a number of upcoming books on Groovy, the documentation is set to improve to.

Ricky Clarkson said...

I expect that Graeme will just be clarifying his own meanings for dynamic and scripted.

The term dynamic is used so widely to mean such different things that it has probably lost its value.

See this wiki page, although there is more real information on its discussion page:


Wikipedia article on dynamic languages

and the Discussion page for it

Conversely, 'dynamically-typed languages' seem to consistently mean languages for which type checking requires runtime information, and this seems to be fairly consistent.

A scripting language seems to be fairly well defined as a language for which the compile stage is not visible, which in itself isn't that great a distinction.

Wikipedia article on Scripting languages

There is a lot of inconsistency around the meanings of strong/weak/static/dynamic/scripting.

Anonymous said...

I always heard something from my neighbor that he sometimes goes to the internet bar to play the game which will use him some hero gold,he usually can win a lot of hero online gold,then he let his friends all have some hero online money,his friends thank him very much for introducing them the hero money,they usually buy hero gold together.