Why Groovy … or JRuby, Jython, Scala, Javascript, or Anything Else?
By Summers Pittman on Tuesday, May 27th, 2008Recently, I attended the No Fluff Just Stuff Atlanta Software Symposium. One of the big buzz terms there was “dynamic languages.” For those of you who don’t have a Computer Science degree, a dynamic language is a programming language which performs many functions at runtime that a static language would perform at compile time.
For instance, a method call in a static language is linked to its code at compile time and is immutable. In a dynamic language, however, this determination is made at runtime. That means that in a language such as Groovy, I can add methods to an object that its class may not have been written to have.
In Java, dynamic features are very difficult to use. The closest thing that it has to a closure, for instance, is the anonymous inner class. Using one is about as simple and elegant as dressing an elephant while performing ballet in a tar pit. In Groovy, however, closures are a first class feature. Also, dynamic code runs on the Java Virtual Machine therefore calling traditional Java code from Groovy or Scala for instance is rather painless.
The next point (which my roommate made) is - “Why would anyone want to do this?” If Java does what you need, albeit painfully at times, there is no need to move off it. If Java doesn’t do what you need, or if it makes it hard to do what you need to do, then Groovy or Scala, or Jython, or JRuby may be useful. It would be foolish to think that any of these are a wholesale replacement for the Java language, but it is equally foolish to think that Java can be the best at doing everything you may need.






