Groovy – a cool JVM based scripting language

Ever thought you are so addicted to Java that although the world is talking about moving to functional languages, you just cannot see yourself leaving the JVM?

Well, as Jerry put it, Groovy could be your solution. You can still use the JVM, but instead of Java, use Groovy as your programming language.

Are there any compelling reasons to move to Groovy or even away from Java to any of the scripting languages on the JVM?

Well, I wouldn't consider myself to be an expert in Java, or any programming language, but from the little experience that I have, I should say, there are some reasons I can think of.

Some time back, we had this requirement. We were doing some project on Eclipse and we had to make changes to a basic Eclipse object because an assumption made by the Eclipse architecture was not true for us. Were we trying to break the architecture of Eclipse? May be. Why were we trying to do it? Well, technological coolness!

Anyway, the point is, this is not possible without actually downloading the source and then making the modification and asking users to replace the original JAR containing that object with ours. Or we need to ask the Eclipse community to accept our change and it might not be a compelling reason for the community. Is there a simpler solution?

How would it be if it was possible to modify this object during runtime and not require anyone to replace the JARs?

Well, although I have not tried it, I am sure it is quite easy to do this with a functional language. I have done some similar changes to Dojo using the 'prototype' property.

There are simpler reasons than that. Java sometimes can get really painful. Remember how painful it is to simply replace backslashes in Java? Remember how painful it is to obtain a substring from the 2nd character at the beginning to the last but one character at the end? Remember how painful it is to write a string of HTML to the response from a servlet? Can setters/getters be simpler? Can XML document creation be simpler?

With the world talking about byte-code modification, metaprogramming and scripting languages on the JVM, Java is becoming more of a platform language than a core programming language. It is more like what C/C++ was about 10 years back and what assembly was before that.

So back to my question on why Groovy.
The Groovy guys have answered it elegantly. Here are the reasons that I found to be the most compelling:
1. It has functional aspects.
2. The syntax is neat and consistent.
3. It is Java based. It is easy to move back to Java if I ever need to. Groovy is completely interoperable with Java and reuses a lot of the Java semantics. If you really need to get this, you should see this tutorial.

So go ahead and give it a try! Who knows, you may soon start to wonder why you were doing Java programming all these days!

Firefox extensions – my picks II (a web developer’s heaven)

Are you into development of scripts using JS and DOM? Do you do AJAXian scripting (using XMLHttp etc)? Then you might have realized the pain of not being able to debug them when faced with problems. A set of 'alert's is not always elegant.

So here's what you do:
1. First things first : Use Firefox
2. Install these extensions.

* Venkman Javascript Debugger : https://addons.mozilla.org/extensions/moreinfo.php?id=216&application=firefox
If you start using this, you will forget that you are using a browser. You will see how the browser is changing into something like an IDE. More about it here.

* Firebug : https://addons.mozilla.org/extensions/moreinfo.php?id=1843&application=firefox
This extension shows you errors that occur during rendering of a page. Click on the line no and it will transfer you to the appropriate line in the appropriate file. Not just this, you can also use this to inspect different values of the HTML DOM, by just clicking inspect element and then clicking the item that you want to inspect and find request/responses of XMLHttp Requests.

* Hypertext DOM browser : https://addons.mozilla.org/extensions/moreinfo.php?id=1584&application=firefox
Yet another cool extension that helps you view the DOM values. This is more 'navigable' than the one that Firebug provides. It also has an evaluator, which helps you to navigate to the appropriate node and then start inspecting the values.

HTML scripting has never been as much fun before!