As an example, Grolifant is a library for allowing Gradle plugins to maintain compatibility over wide range of Gradle releases. Currently this range is Gradle 4.3 - 8.5. Public interfaces are written in Java, but 99% of implementations are done in Groovy. Anything Groovy & public is statically compiled, but sometimes under the hood (read private methods), dynamic methods are required to deal with changes in the Gradle API. Trying to do that with Java or Kotlin as an implementation language will be a nightmare. Groovy is really good for some stuff!

On 30/12/2023 19:57, Christopher Smith wrote:
I typically use Groovy in its static mode, and the single biggest value to me is the AST-transformation system. However, there are cases where I find dynamic mode very useful.

1. Methods that handle processing for particular subtypes of a base type. I could do something like a class-based map with, and I do in cases where I need pluggability, but for the case of "I have these 4 types of incoming message and need to convert them to a target format", using dynamic dispatch on a top-level method results in much clearer code than a giant switch or hand-written reflection.

2. Quick-and-dirty processing of data structures. REST calls usually return JSON these days, and if I know that I just to pull some simple data out of a nested structure, it's much easier to use dynamic mode against a Map than to try to write a bunch of mapping classes.

3. Spock and Geb. I have managed to convince consulting clients that stick to plain Java only for the business code to adopt Spock for testing because it's so powerful and clear. Spock is the Groovy equivalent of an IOCCC winner, and it showcases the dramatic lengths you can (and nearly all of us shouldn't) go to.

On Sat, Dec 30, 2023 at 12:17 PM Agile Developer <fithis2...@gmail.com> wrote:

    Hi,

    I was a  4 years user of Grails/Groovy (last year mostly Python).
    With the general trend of people moving to static languages, is
    there any reason that Groovy needs to stay dynamic?

    I see Python having the mypy approach, I see gradle moving to
    Kotlin and FE mostly on Typescript.

    I understand that the @CompileStatic is the supported method, but
    having true static typing (with the Script-Like enhancements other
    Languages added, would be beneficial).

    Is there still a reason to keep it dynamic? What is the benefit?

-- Dr. Vasileios Anagnostopoulos (MSc,PhD)
    Researcher/Developer

--
Schalk W. Cronjé
Fediverse: @ysb33r@mastodon.social (general), @ysb33r@mountains.social 
(outdoor), @ysb33r...@fosstodon.org (open-source work).
Twitter / Ello: @ysb33r

Reply via email to