groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MG <>
Subject Consider statically typed/compiled as default for Groovy 3.0
Date Thu, 12 Oct 2017 20:30:33 GMT
blackdrag suggested to move this
discussion from Jira to this list, so I am replying here:

I agree with Endre StĂžlsvik: I think Groovy should strengthen its 
language support for statically compiled use, and I agree it should move 
towards making statically using it as hassle free as possible.

I think Endre has already made some good points why this would be a good 
idea, so I am just going to add that I am convinced that Groovy would 
not be at 3% of the languages used after Java, but at > 30% (basically 
everyone that could freely pick a language for commercial projects 
besides Java would be using it) if it would fully be the Java++ it in 
fact is - in my perception what kept it back was the fact that it "is 
slow" (true > 10 years back), that it is just "a script language" (never 
true afaik) - and that it "is a dynamic language" (no longer true, 
but...). When I picked Groovy for the project I work on, I did so 
despite it was dynamic, not because of that (the static Groovy compiler 
that someone in Russia had built at the time helped in the decision...).

Being able to be dynamic in a language is a powerful feature, but one 
that is needed only in special cases. Otherwise Groovy would already 
rule the Java world ;-)

Being able to have a very simple configscript that qualifies every class 
with @CompileStatic is great 
but it is not simple/easy enough: I agree there should be a "one click" 
option to turn all of Groovy to using static compilation by default.

Some ways to achieve this:
# Make a "static Groovy" download available (might just be based on 
"including" the @CompileStatic configscript above)
# Compiler switch
# Choose during installation
# Express through the Groovy source file extension:
## *.groovy ... use configured default
## *.groovyd ... dynamic
## *.groovys ... static
(alternatives: *.groovys, *.sgrv, *.grvs)

The last option has the advantage, that everybody can use it easily 
everwhere (Shell, IDE, ...), but the disadvantage that all the Groovy 
examples out there use *.groovy, which would again might give the 
impression to people that Groovy is "mostly a dynamic language". Maybe a 
combination of people picking the default mode (dynamic/static) at 
download/install time, with the extension approach would work best.
(That the Groovy compiler will try to compile any file with any 
extension is OK. In that case I would suggest the fallback if the 
extension is not known is dynamic compilation, for backward 
compatibility reasons. Configuring extensions to mean dynamic or static 
compilation would of course also be an option).
Or the Groovy compiler could throw if no --static or --dynamic compiler 
switch was given ? That would force everyone to make a deliberate 
decision... ;-)

Just a quick brainstorming mail, to hopefully get the discussion going,

View raw message