Python Programming Portal
Python Programming Portal
J2EE curve
Add Site Feed
There’s no compelling reason to choose Groovy over Jython. PDF Print E-mail
Written by Content Team   
Sunday, 16 April 2006

X vs Y always makes for good reading. We will have a look at a nice excerpt from a recent interview with Guillaume Laforge, he shares his views on Groovy vs Jython comparison.

Guillaume Laforge is the project manager for Groovy and the initiator of Grails, His views on scripting languages helps us understand what are scripting languages and the need of scripting languages.


X vs Y always makes for good reading. Can I interest you in a Groovy vs Jython comparison?

Guillaume Laforge >>
To be frank, I’m not really interested in making such comparisons. There are many reasons for that. First of all, I don’t know the other languages for the JVM well enough to be able to make fair comparisons. I also don’t want to spread false assertions because of my biased views. And one last reason is I don’t want to “fight” with others on the tune “mine is better than yours”, because it’s a waste of time, and because we’re on the same boat! We all want good scripting languages to embed in our applications, or to write standalone applications!

"We all want good scripting languages to embed in our applications, or to write standalone applications..."

If you’ve been programming in Python for several years, you’ll be at home with Jython, so I guess there’s no compelling reason to choose Groovy if your teammates know Python well. Same thing for JRuby if you already know Ruby well. If you prefer a pure Java syntax with possible weak typing, BeanShell is perfect too. If you also want a Java-like syntax, but with the possibility to use powerful APIs and to be able to do advanced class manipulations with the Groovy Meta-Object Protocol, then Groovy might be a better fit.

"There’s no compelling reason to choose Groovy (over Jython) if your teammates know Python well..."

GuillaumeLaforgeGroovyThe confusion with scripting languages really begins with the word scripting. Very few Java developers are sure of what is scripting. To add to it, these languages are also referred to as agile or dynamic. Could you help us understand what are scripting languages and what's the need?

Guillaume Laforge >>
It’s tough to give definitions for these words! Because almost everybody has its own definition of what scripting, dynamic or agile mean. So I’ll give you my own definitions instead – some might disagree with this classification.

"Everybody has an own definition of what scripting, dynamic or agile means ...."

Usually, scripting languages refer to languages which are interpreted, but not compiled. They are mostly used and live on the command-line, in shell environments, like bash. Those languages are often used to “script” some live applications, objects or components, to manipulate them programmatically, and potentially interactively.
Agile is often used to refer to language that offer some syntax sugar or simplified APIs to do some common and somewhat complex tasks in an easier way, giving you more productivity gains than a general-purpose language. The idea is to help you do complex tasks easily, either by providing simple APIs or by giving you an expressive syntax.

Then comes the term “dynamic”… it conveys two distinct meanings, but it is often used mistakenly interchangeably for those two meanings. Languages that are “dynamic” are often called so because they support “dynamic typing”, or weak typing: you can omit type information when passing parameters or defining new variables or fields. It is different than say in Java which is strongly typed and requires you to prefix every parameter, or instance with a type upon declaration. Talking about dynamic languages this is a bit misleading; we should say dynamically-typed languages instead, to be more accurate.

The second meaning of “dynamic” is more interesting in that is refers to languages that offer some kind of dynamic features in the form of meta-programming capabilities. Then you might ask what is meta-programming? It’s like programming, expanding, extending, manipulating the language constructs themselves. For example: adding new methods on an object at runtime, intercept non-existent method calls, injecting or changing the behavior of an object. We also speak about the MOP: the Meta-Object Protocol, which represents all the manipulations you can do on your language and its constructs.

If we take those definitions for granted – and I know some may disagree with my own definitions – Groovy is a scripting language because it can be interpreted at runtime, despite it can also be pre-compiled as normal Java classes are (in the form of .class files full of bytecode instructions). But Groovy is also a dynamic language in both senses of the term: it can be dynamically typed (though it also supports static typing), and it also offers a MOP, a way to add and manipulate language constructs to extend its capabilities.

As to what’s the need of those families of languages, it really depends on your use case. In a lot of cases, you won’t need such a language, and you’d probably better use a full-blown statically-typed language with a nice IDE to work with. But scripting languages come in handy for prototyping spikes, for small to mid-sized projects where the expressivity matters more, or for integrating some customized logic to be interpreted or changed at runtime for bigger enterprise applications.

"Scripting languages come in handy for prototyping spikes, for small to mid-sized projects or for integrating some customized logic ...."

You can read the entire interview @ Groovy bridges the scripting and the enterprise Java worlds

Comments

You must javascript enabled to use this form


Add Python Site Feed
Latest
Popular
Go to top of page  Home | Content | Resources | Contact Us | Blogs |

Copyright 2004 Rightrix Solutions. All rights reserved. All product names are trademarks of their respective companies.
Views expressed at PythonThreads.com reflect the views of the authors alone, and do not necessarily reflect those of PythonThreads.com.

Terms of Use          Privacy Policy
PythonThreads.com - Python Programming Language Portal