Mike Gage wrote:Is there an advantage to using Clojure rather than Groovy?
In many ways Clojure and Groovy are closer in syntax than Clojure and
Java. If you take the Class definitions out of Groovy and just have functions, you would see many similarities in syntax. However, (please correct me if I am wrong), Grovvy is still based around an OOP approach rather than a functional programming approach. Not that you cant write functional code in Groovy I am sure, I just havent seen the language constructs that make it a natural thing to do. For parallelism, there is a great library for Groovy called GPars, but have not worked with this or looked at the code.
The immutable nature of Clojure is certainly different from what I understand of Groovy. With Clojure, immutable data structures (list, map, vector, set) are baked into the language. When you define one of these data structures (collectively know as sequences) it is immutable, you dont need to qualify it with anything else. In Groovy (and Java) you have to explicitly define something as immutable (using final / final static).
For example, if you create a list with the contents (a, b, c) then the contents of that list cant change. If you want to change that list then Clojure actually creates a new list for you under the covers, so anyone code still processing the original list will remain unaffected. You can change the names you use to reference a list, but the underlying list cant change.
Both Clojure and Groovy are dynamic and have a runtime environment (REPL). Use of the REPL is something that Clojure developers make use of heavily, I have not seen as much of this with Groovy developers, but that’s just my experience. Tooling support is good for both languages in
IDE's such as Netbeans, Eclipse and Intellij. Many Clojure developers use Emacs or Vim as a lighter weight development environment that IDE's. Clojure and Groovy both have great build tools, Leiningen for Clojure and Graddle for Groovy (and other languages).
There are probably many similarities and differences between Clojure and Groovy, although my Groovy is a bit too rusty to offer a more in-depth comparison. I'd state that the main one is the paradigm each language uses, functional vs OOP.
Thank you
John Stevenson