3 ms·
I think I conflate the two, and I'm not sure that's wrong. I've never seen anyone use Groovy outside Gradle. I mean why would you, if you had a choice?
by mrec 6y ago
I think I conflate the two, and I'm not sure that's wrong. I've never seen anyone use Groovy outside Gradle. I mean why would you, if you had a choice?
- tamasnet 6y agoGroovy is fantastic for quickly creating domain specific languages. I've done a bunch of them over the years for different problem domains and have yet to find another solution that yields effective custom languages that are as readable and easy to implement.
- michaelcampbell 6y agoI have an old java (7, 8) app I maintain that whenever possible I move classes to Groovy as I am making other changes in them. I would probably do Kotlin, now, but that wasn't an option when I started this. The amount of boilerplate removed is one big win, but moreover the more functionally oriented aspects of most anything you'd do with a for-loop in java is wonderful. And with annotations such as @CompileStatic and @TypeChecked, I am able to forgo SOME of the syntactic niceties for the compile-time binding java-comparable speed.
- Tainnor 6y agoBack in the days when Kotlin didn't exist and even Scala was in its infancy, some people genuinely liked the JVM ecosystem and even aspects of Java itself, but were turned off by the verbosity of Java. Those were the people that started using Groovy and also projects such as Grails (especially since they saw the success of Rails and Django and wanted to emulate that). Also, I guess some people genuinely like gradual typing, although I've never found much use for it. Nowadays, I wouldn't pick up Groovy anymore, but there was a time where it was basically that, or Java (or a different ecosystem entirely; or something like JRuby / Jython).
- imtringued 6y agoThere are worse things than using Grails. For example using straight up Spring. Grails is a sane wrapper around Spring so you can easily bring regular Java developers into a sane ecosystem. For example Grails' Gorm is the only sane way of using Hibernate in the entire JVM ecosystem. Using Hibernate directly will drain your sanity very quickly.
- cataphract 6y agoEspecially before Java 8, writing Java code was very painful compared with Groovy, even though Groovy was fairly slower, and its compiler buggy. Groovy has closures, AST transformations builtin, much nicer syntax for properties (backed by getters/setters), ability to sort-of change classes at runtime (without instrumentation), multiple dispatch (i.e. dispatch based on the runtime type of the arguments), the ability to use reflection without the awful reflection API and so on.
- McP 6y agoI've had to use it to configure Jenkins. In Groovy, variables are global if you forget to declare them with 'var'. This has caused so many concurrency bugs and so much sadness.
- zmmmmm 6y agoGroovy is an amazing language. Don't judge it based on Gradle. It is used for all kinds of things. Gradle sort of interacts with it in a highly toxic way and brings out all its bad parts. If you use it the opposite way - as a better version of Java with mostly structured code, plenty of explicit typing and avoiding the highly "magic" aspects that Gradle focuses on, then its a great language for application development. Certainly better for high level things than Java - but completely 100% compatible with the Java ecosystem.
- Too 6y agoCould you link to any githubs with examples of such good groovy?
- zmmmmm 6y agoYou could have a look at something like Geb - this is a completely random class I picked: https://github.com/geb/geb/blob/master/module/geb-core/src/main/groovy/geb/content/DefaultPageContentSupport.groovy https://github.com/geb/geb/blob/master/module/geb-core/src/m... So it looks mostly like Java, its just making use of Groovy's niceties and more powerful constructs in various parts to make the coding nicer.
- dvdgsng 6y agoJenkins uses groovy for scripted build Pipelines, works pretty well and makes Jenkins a bit more fun to use, if that is even a thing.