A Groovy Kind of Relationship
What are the pros and cons of using Groovy? Jennifer Strater, former Engineer at Zenjob, and Ash Davies, Senior Software Engineer at ImmobilienScout24, talk to us about their experiences using the programming language, why Jenn spends less time “banging her head against the wall than with other languages” and why Ash thinks that “developing with Groovy can be frustrating sometimes”.
- How long have you been working with Apache Groovy and what do you use Groovy for?
I also use Groovy in other ways like for writing build scripts using Gradle, scripting the deployment pipeline in Jenkins, and automating UI tests using Geb.
Ash: Working with the Android development for the last five years, I’ve become familiar with Groovy and Gradle for building build scripts, for Android applications themselves, for our continuous integration servers, building reports and deployment scripts.
2. What makes Apache Groovy unique in comparison to other programming languages?
Jenn: Groovy is unique because it’s very flexible. Many people know Groovy for its use as a dynamic, scripting language, but it’s so much more than that. Groovy supports optional typing and static compilation.
It’s also incredibly powerful as a language for creating Domain Specific Languages (DSLs). This is how tools like Gradle and Jenkins use Groovy. It’s also interesting to note the case studies from Mutual of Omaha where they created a DSL for their actuaries to use.
Ash: Generally Groovy shared similarities with many other loosely typed languages, in that you can define programming constructs without having to comply to many difficulties of static compilation (optionally).
Interestingly, Groovy allows for a lot of syntax sugar that wouldn’t ordinarily be available in Java, such as null coalescing, or string interpolation, though these features are also available in languages such as Kotlin, it’s quite nice that this is included with Groovy.
3. What are pros and cons when using Apache Groovy?
Jenn: Although the flexibility of Groovy can be advantageous in many cases, it also comes with a few cons. Most are summarized with the expression, “With great power comes great responsibility”. With Groovy, that means it’s important to have well-trained developers who follow good practices like writing tests, participating in code reviews, running static analysis tools, and enforcing Continuous Integration (CI) and Continuous Delivery (CD) best practices.
Ash: In a build environment Groovy becomes quite advantageous due to having much more control of the environment, but can often be a disadvantage too, since developers will often not fully understand the sequence of operation, and try desperately to get something to work by any means, resulting in bad practices.
Additionally when working with Android, it can be quite difficult to make use of the plugin APIs as it’s quite a bit harder to find the implementation, so you’re at the mercy of the public documentation, which is often out-of-date, or difficult to read.
4. Do you think Apache Groovy is becoming more popular?
Jenn: Definitely! The download numbers and various surveys show that Groovy is increasing in use, but you don’t see as many news articles and conferences talks about it. Apache Groovy is often referred to as the most used JVM language no one is talking about.
One of the reasons for that is that there are no paid developer advocates for Groovy. It also means there is no single company making all the decisions and the language grows through its strong community of individual contributors.
Ash: There will always be innate enthusiasm for some languages, but Groovy seems to be something most developers have used at some point in their life, but perhaps haven’t found the necessity to advocate for, its flexibility affords a lot of usefulness for specific use-cases, but perhaps doesn’t find itself at the center of attention when compared to other more “exciting” languages.
5. What have you learned from working with Groovy? What tips can you give when working with Groovy in a team?
Jenn: After working with Groovy for several years, I’ve learned that it can be a very powerful tool for creating web applications. The reduction of boilerplate code means that I can also finish tasks much faster and with fewer redundancies.
My suggestion would be to learn the language properly by reading the Groovy in Action book, going to conferences, or taking training classes — whatever works for your learning style. It’s also very important to enforce good development practices from the beginning so that the whole team can benefit from becoming more Groovy.
6. Can everyone in your team program in Groovy?
Jenn: That’s actually a really great question. At Zenjob, everyone in the backend, Infrastructure Automation, Android, and QA teams has at least some experience with Groovy. For now, the backend team uses Groovy, in particular, the framework Grails, for the core business application, and writes automated tests using Spock. Both the backend and Android teams use Gradle as a build tool, although the Android team has switched to use Kotlin now. Geb, a Groovy and Spock-based framework built on top of Selenium is used by the Test Automation team to write UI tests that run in test containers.
Ash: Everybody in our team has at some point used Groovy, if only to appease our build system, though I wouldn’t say they have an in-depth knowledge of it.
At the moment we are evaluating whether to use Kotlin instead of Groovy, as it allows for better type safety and can facilitate a more intimate knowledge of the Android Gradle Plugin API.
7. Did you ever bang your head against the wall because of the groovy code?
Jenn: Absolutely! I mean… I definitely spend less time banging my head against the wall than with other languages, but there are tricky parts to every language including Groovy.
At some Groovy conferences, like GR8Conf, we have a session called Groovy Puzzlers that points out some of the tricky problems or bugs in the current version of the language. In addition to educating fellow devs about the tricky parts of the languages, the feedback from Groovy Puzzlers also helps prioritize which bugs and problems should be fixed next.
Ash: Every… single.. day.
What about you and Groovy? If you are having problems with something in Groovy, feel free to post the question on StackOverflow or you can contact Jenn directly and she’ll connect you with the right person to answer your question. If you are interested in Android, don’t hesitate to drop Ash a line.