I have had the opportunity to work with Groovy quite a bit and I will share a few of my thoughts on things that work well with the language and things that are a bit questionable.
Works well:
Extensible type checking. Groovy can do quite a bit of things with type checking and you can turn it into "pretty much Java" if you need to and even take it a step further and enforce even stricter typing than Java with relative ease
Closures. The Groovy built in closures are quite extensive and allow you to build some really beautifully expressive pieces of code that would be 5 to 10 times longer in Java. The implementation lends itself well to a functional approach.
Questionable:
Not defining a variable with a type or the def keyword creates a variable in the global scope, just like JavaScript. This creates problems, as you can imagine. One of the more infamous bugs we ran into was when someone had named a variable "id" in the global scope of a script and the identifier of its parent, the script runner, was modified. Brought the whole runner down.
Groovy doesn't respect privacy. You can literally declare something as private variable in a Java or Groovy class and Groovy will happily access it with no qualms. The only thing that private helps you for is preventing the variable from showing up in a decent IDE's autocomplete alongside your getters and setters
I wonder if that's Java 8 with its lambdas? Most sites just use Apache Groovy for the scripty dynamically-typed stuff only (e.g. testing, build config, grails MOP) and leave the statically-typed stuff for Java or some other JVM language. Of course, those variables in global scope will still be a problem.
[+] [-] SOLAR_FIELDS|9 years ago|reply
Works well:
Extensible type checking. Groovy can do quite a bit of things with type checking and you can turn it into "pretty much Java" if you need to and even take it a step further and enforce even stricter typing than Java with relative ease
Closures. The Groovy built in closures are quite extensive and allow you to build some really beautifully expressive pieces of code that would be 5 to 10 times longer in Java. The implementation lends itself well to a functional approach.
Questionable:
Not defining a variable with a type or the def keyword creates a variable in the global scope, just like JavaScript. This creates problems, as you can imagine. One of the more infamous bugs we ran into was when someone had named a variable "id" in the global scope of a script and the identifier of its parent, the script runner, was modified. Brought the whole runner down.
Groovy doesn't respect privacy. You can literally declare something as private variable in a Java or Groovy class and Groovy will happily access it with no qualms. The only thing that private helps you for is preventing the variable from showing up in a decent IDE's autocomplete alongside your getters and setters
[+] [-] vorg|9 years ago|reply
I wonder if that's Java 8 with its lambdas? Most sites just use Apache Groovy for the scripty dynamically-typed stuff only (e.g. testing, build config, grails MOP) and leave the statically-typed stuff for Java or some other JVM language. Of course, those variables in global scope will still be a problem.
[+] [-] geooooooooobox|9 years ago|reply