Is it possible to enable CompileStatic for an entire project

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
55 messages Options
1234 ... 6
Reply | Threaded
Open this post in threaded view
|

Is it possible to enable CompileStatic for an entire project

Mr Andersson
Is it possible to enable CompileStatic for an entire project?

Or do you have to do it on a per class basis?

I like Groovy for some of it's features, and mostly for it's close to
Java syntax but I would really like it to be a static language.

I've heard about Groovy++ but I believe that's dead by now, no?

Question is wether you can tell the Groovy compiler with a flag to treat
all Groovy classes on certain paths as static?

Preferable doable from ANT too.


Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to enable CompileStatic for an entire project

Cédric Champeau

2016-06-21 14:24 GMT+02:00 Mr Andersson <[hidden email]>:
Is it possible to enable CompileStatic for an entire project?

Or do you have to do it on a per class basis?

I like Groovy for some of it's features, and mostly for it's close to Java syntax but I would really like it to be a static language.

I've heard about Groovy++ but I believe that's dead by now, no?

Question is wether you can tell the Groovy compiler with a flag to treat all Groovy classes on certain paths as static?

Preferable doable from ANT too.



Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to enable CompileStatic for an entire project

ysb33r
On 21/06/2016 13:29, Cédric Champeau wrote:
> It's in the docs:
> http://docs.groovy-lang.org/latest/html/documentation/#_static_compilation_by_default
I am wondering how (or if) IntelliJ would recognise that?

--
Schalk W. Cronjé
Twitter / Ello / Toeter : @ysb33r

Reply | Threaded
Open this post in threaded view
|

RE: Is it possible to enable CompileStatic for an entire project

Winnebeck, Jason
In reply to this post by Cédric Champeau

Tying Cédric’s advice to your previous question about gmavenplus and joint compilation, per https://github.com/groovy/GMavenPlus/wiki/Examples#configuration-script you add the configuration tag with a reference to your groovy script.

 

Actually about 90+% of our code base in Groovy is CompileStatic I wonder if we should use that. Cédric, if we use the config script method, is it still possible to use the “skip” annotation to switch back to dynamic mode? Even if it worked, I highly doubt IntelliJ IDEA would know about it and think all files are dynamic typing so probably it’s still best for us to add @CompileStatic everywhere, but sometimes we forget where we wanted it. The performance difference is extreme when we forget it, on a certain class we missed recently it took our page rendering times from about 4ms to 52ms, so for us it’s an actual “bug” to forget to add @CompileStatic.

 

Jason

 

From: Cédric Champeau [mailto:[hidden email]]
Sent: Tuesday, June 21, 2016 8:29 AM
To: [hidden email]
Subject: Re: Is it possible to enable CompileStatic for an entire project

 

 

2016-06-21 14:24 GMT+02:00 Mr Andersson <[hidden email]>:

Is it possible to enable CompileStatic for an entire project?

Or do you have to do it on a per class basis?

I like Groovy for some of it's features, and mostly for it's close to Java syntax but I would really like it to be a static language.

I've heard about Groovy++ but I believe that's dead by now, no?

Question is wether you can tell the Groovy compiler with a flag to treat all Groovy classes on certain paths as static?

Preferable doable from ANT too.

 


This email message and any attachments are for the sole use of the intended recipient(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message and any attachments.
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to enable CompileStatic for an entire project

Thibault Kruse
I would prefer to have a codenarc rule enforcing @CompileStatic for
projects requiring it that way.

On Tue, Jun 21, 2016 at 2:38 PM, Winnebeck, Jason
<[hidden email]> wrote:

> Tying Cédric’s advice to your previous question about gmavenplus and joint
> compilation, per
> https://github.com/groovy/GMavenPlus/wiki/Examples#configuration-script you
> add the configuration tag with a reference to your groovy script.
>
>
>
> Actually about 90+% of our code base in Groovy is CompileStatic I wonder if
> we should use that. Cédric, if we use the config script method, is it still
> possible to use the “skip” annotation to switch back to dynamic mode? Even
> if it worked, I highly doubt IntelliJ IDEA would know about it and think all
> files are dynamic typing so probably it’s still best for us to add
> @CompileStatic everywhere, but sometimes we forget where we wanted it. The
> performance difference is extreme when we forget it, on a certain class we
> missed recently it took our page rendering times from about 4ms to 52ms, so
> for us it’s an actual “bug” to forget to add @CompileStatic.
>
>
>
> Jason
>
>
>
> From: Cédric Champeau [mailto:[hidden email]]
> Sent: Tuesday, June 21, 2016 8:29 AM
> To: [hidden email]
> Subject: Re: Is it possible to enable CompileStatic for an entire project
>
>
>
> It's in the docs:
> http://docs.groovy-lang.org/latest/html/documentation/#_static_compilation_by_default
>
>
>
> 2016-06-21 14:24 GMT+02:00 Mr Andersson <[hidden email]>:
>
> Is it possible to enable CompileStatic for an entire project?
>
> Or do you have to do it on a per class basis?
>
> I like Groovy for some of it's features, and mostly for it's close to Java
> syntax but I would really like it to be a static language.
>
> I've heard about Groovy++ but I believe that's dead by now, no?
>
> Question is wether you can tell the Groovy compiler with a flag to treat all
> Groovy classes on certain paths as static?
>
> Preferable doable from ANT too.
>
>
>
> ________________________________
> This email message and any attachments are for the sole use of the intended
> recipient(s). Any unauthorized review, use, disclosure or distribution is
> prohibited. If you are not the intended recipient, please contact the sender
> by reply email and destroy all copies of the original message and any
> attachments.
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to enable CompileStatic for an entire project

Charles G
for classes I want to be dynamic -- or is it for methods only?

Docs: http://docs.groovy-lang.org/next/html/gapi/groovy/transform/CompileStatic.html  seem to make it seem like you can only use it on methods?

 

On Tue, Jun 21, 2016 at 7:40 AM, Thibault Kruse <[hidden email]> wrote:
I would prefer to have a codenarc rule enforcing @CompileStatic for
projects requiring it that way.

On Tue, Jun 21, 2016 at 2:38 PM, Winnebeck, Jason
<[hidden email]> wrote:
> Tying Cédric’s advice to your previous question about gmavenplus and joint
> compilation, per
> https://github.com/groovy/GMavenPlus/wiki/Examples#configuration-script you
> add the configuration tag with a reference to your groovy script.
>
>
>
> Actually about 90+% of our code base in Groovy is CompileStatic I wonder if
> we should use that. Cédric, if we use the config script method, is it still
> possible to use the “skip” annotation to switch back to dynamic mode? Even
> if it worked, I highly doubt IntelliJ IDEA would know about it and think all
> files are dynamic typing so probably it’s still best for us to add
> @CompileStatic everywhere, but sometimes we forget where we wanted it. The
> performance difference is extreme when we forget it, on a certain class we
> missed recently it took our page rendering times from about 4ms to 52ms, so
> for us it’s an actual “bug” to forget to add @CompileStatic.
>
>
>
> Jason
>
>
>
> From: Cédric Champeau [mailto:[hidden email]]
> Sent: Tuesday, June 21, 2016 8:29 AM
> To: [hidden email]
> Subject: Re: Is it possible to enable CompileStatic for an entire project
>
>
>
> It's in the docs:
> http://docs.groovy-lang.org/latest/html/documentation/#_static_compilation_by_default
>
>
>
> 2016-06-21 14:24 GMT+02:00 Mr Andersson <[hidden email]>:
>
> Is it possible to enable CompileStatic for an entire project?
>
> Or do you have to do it on a per class basis?
>
> I like Groovy for some of it's features, and mostly for it's close to Java
> syntax but I would really like it to be a static language.
>
> I've heard about Groovy++ but I believe that's dead by now, no?
>
> Question is wether you can tell the Groovy compiler with a flag to treat all
> Groovy classes on certain paths as static?
>
> Preferable doable from ANT too.
>
>
>
> ________________________________
> This email message and any attachments are for the sole use of the intended
> recipient(s). Any unauthorized review, use, disclosure or distribution is
> prohibited. If you are not the intended recipient, please contact the sender
> by reply email and destroy all copies of the original message and any
> attachments.

Reply | Threaded
Open this post in threaded view
|

RE: Is it possible to enable CompileStatic for an entire project

Winnebeck, Jason

The annotations also work on classes, per the documentation:

 

When a class is annotated, all methods, properties, files, inner classes, etc. of the annotated class will be type checked. When a method is annotated, static compilation applies only to items (closures and anonymous inner clsses) within the method.

 

Jason

 

From: Charles G [mailto:[hidden email]]
Sent: Tuesday, June 21, 2016 11:39 AM
To: [hidden email]
Subject: Re: Is it possible to enable CompileStatic for an entire project

 

for classes I want to be dynamic -- or is it for methods only?


Docs: http://docs.groovy-lang.org/next/html/gapi/groovy/transform/CompileStatic.html  seem to make it seem like you can only use it on methods?

 

 

 

On Tue, Jun 21, 2016 at 7:40 AM, Thibault Kruse <[hidden email]> wrote:

I would prefer to have a codenarc rule enforcing @CompileStatic for
projects requiring it that way.


On Tue, Jun 21, 2016 at 2:38 PM, Winnebeck, Jason
<[hidden email]> wrote:
> Tying Cédric’s advice to your previous question about gmavenplus and joint
> compilation, per
> https://github.com/groovy/GMavenPlus/wiki/Examples#configuration-script you
> add the configuration tag with a reference to your groovy script.
>
>
>
> Actually about 90+% of our code base in Groovy is CompileStatic I wonder if
> we should use that. Cédric, if we use the config script method, is it still
> possible to use the “skip” annotation to switch back to dynamic mode? Even
> if it worked, I highly doubt IntelliJ IDEA would know about it and think all
> files are dynamic typing so probably it’s still best for us to add
> @CompileStatic everywhere, but sometimes we forget where we wanted it. The
> performance difference is extreme when we forget it, on a certain class we
> missed recently it took our page rendering times from about 4ms to 52ms, so
> for us it’s an actual “bug” to forget to add @CompileStatic.
>
>
>
> Jason
>
>
>
> From: Cédric Champeau [mailto:[hidden email]]
> Sent: Tuesday, June 21, 2016 8:29 AM
> To: [hidden email]
> Subject: Re: Is it possible to enable CompileStatic for an entire project
>
>
>
> It's in the docs:
> http://docs.groovy-lang.org/latest/html/documentation/#_static_compilation_by_default
>
>
>
> 2016-06-21 14:24 GMT+02:00 Mr Andersson <[hidden email]>:
>
> Is it possible to enable CompileStatic for an entire project?
>
> Or do you have to do it on a per class basis?
>
> I like Groovy for some of it's features, and mostly for it's close to Java
> syntax but I would really like it to be a static language.
>
> I've heard about Groovy++ but I believe that's dead by now, no?
>
> Question is wether you can tell the Groovy compiler with a flag to treat all
> Groovy classes on certain paths as static?
>
> Preferable doable from ANT too.
>
>
>
> ________________________________
> This email message and any attachments are for the sole use of the intended
> recipient(s). Any unauthorized review, use, disclosure or distribution is
> prohibited. If you are not the intended recipient, please contact the sender
> by reply email and destroy all copies of the original message and any
> attachments.

 


This email message and any attachments are for the sole use of the intended recipient(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message and any attachments.
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to enable CompileStatic for an entire project

Mr Andersson
In reply to this post by Winnebeck, Jason


On 06/21/2016 02:38 PM, Winnebeck, Jason wrote:

Tying Cédric’s advice to your previous question about gmavenplus and joint compilation, per https://github.com/groovy/GMavenPlus/wiki/Examples#configuration-script you add the configuration tag with a reference to your groovy script.

 

Actually about 90+% of our code base in Groovy is CompileStatic I wonder if we should use that. Cédric, if we use the config script method, is it still possible to use the “skip” annotation to switch back to dynamic mode? Even if it worked, I highly doubt IntelliJ IDEA would know about it and think all files are dynamic typing so probably it’s still best for us to add @CompileStatic everywhere, but sometimes we forget where we wanted it. The performance difference is extreme when we forget it, on a certain class we missed recently it took our page rendering times from about 4ms to 52ms, so for us it’s an actual “bug” to forget to add @CompileStatic.


Not to mention the fact that if you wish to enforce it across the organisation, you can't rely on start misusing the dynamic nature of Groovy.

Therefore, a default CompileStatic setting and a CompileDynamic annotation and you could track all of the dynamic usages easily in your editor. A missing CompileStatic is difficult to track.

 

Jason

 

From: Cédric Champeau [[hidden email]]
Sent: Tuesday, June 21, 2016 8:29 AM
To: [hidden email]
Subject: Re: Is it possible to enable CompileStatic for an entire project

 

 

2016-06-21 14:24 GMT+02:00 Mr Andersson <[hidden email]>:

Is it possible to enable CompileStatic for an entire project?

Or do you have to do it on a per class basis?

I like Groovy for some of it's features, and mostly for it's close to Java syntax but I would really like it to be a static language.

I've heard about Groovy++ but I believe that's dead by now, no?

Question is wether you can tell the Groovy compiler with a flag to treat all Groovy classes on certain paths as static?

Preferable doable from ANT too.

 


This email message and any attachments are for the sole use of the intended recipient(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message and any attachments.

Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to enable CompileStatic for an entire project

Mr Andersson
In reply to this post by Winnebeck, Jason


On 06/21/2016 02:38 PM, Winnebeck, Jason wrote:

Tying Cédric’s advice to your previous question about gmavenplus and joint compilation, per https://github.com/groovy/GMavenPlus/wiki/Examples#configuration-script you add the configuration tag with a reference to your groovy script.

I also mentioned that I could not get Gmavenplus to work, but maybe i did something wrong. But I literally copied and pasted that section.

 

Actually about 90+% of our code base in Groovy is CompileStatic I wonder if we should use that. Cédric, if we use the config script method, is it still possible to use the “skip” annotation to switch back to dynamic mode? Even if it worked, I highly doubt IntelliJ IDEA would know about it and think all files are dynamic typing so probably it’s still best for us to add @CompileStatic everywhere, but sometimes we forget where we wanted it. The performance difference is extreme when we forget it, on a certain class we missed recently it took our page rendering times from about 4ms to 52ms, so for us it’s an actual “bug” to forget to add @CompileStatic.


The problem with  the ANT task is that I don't think I can set classpath argumetns to the actual so passing the config location is a problem that needs be resolved. Not that easy with maven.

Groovy should instead provide a default GroovyStatic-2.4.4.jar file that enables this by default. That way everybody wins, and Groovy could join the club of static languages and not get rejected by those that needs to get Groovy.

It is also messy to set up config files for every maven module, although I am not sure. The code in that config file is also not dynamic.

withConfig(configuration) { ast(groovy.transform.CompileStatic) } and a simple option -compileStatic that uses an internal version of that file is preferable and SIMPLER.
groovyc -configscript src/conf/config.groovy src/main/groovy/MyClass.groovy
Is not needed here.


 

Jason

 

From: Cédric Champeau [[hidden email]]
Sent: Tuesday, June 21, 2016 8:29 AM
To: [hidden email]
Subject: Re: Is it possible to enable CompileStatic for an entire project

 

 

2016-06-21 14:24 GMT+02:00 Mr Andersson <[hidden email]>:

Is it possible to enable CompileStatic for an entire project?

Or do you have to do it on a per class basis?

I like Groovy for some of it's features, and mostly for it's close to Java syntax but I would really like it to be a static language.

I've heard about Groovy++ but I believe that's dead by now, no?

Question is wether you can tell the Groovy compiler with a flag to treat all Groovy classes on certain paths as static?

Preferable doable from ANT too.

 


This email message and any attachments are for the sole use of the intended recipient(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message and any attachments.

Reply | Threaded
Open this post in threaded view
|

Re: Is it possible to enable CompileStatic for an entire project

Cédric Champeau
A strong -1 for both options. We already have 2 variants of Groovy today, indy and non indy, and in practice *nobody uses the invokedynamic version* because it's impractical to use. Typically projects depend on `groovy.jar` or `groovy-all.jar`, not their invokedynamic version. Adding a new dimension, which is orthogonal to invokedynamic makes it even more complicated. Don't forget that the Groovy compiler is also mixed in its runtime (which is a problem of its own). We should solve that first.

Second, IDEs need to know whether a file is statically compiled or not. The `@CompileStatic` annotation makes it very clear, and the default is the standard dynamic mode that has been in Groovy for more than 10 years. IDEs know about it, and it's simple to infer. Any alternative solution, like the config script, or an alternate compiler (!) makes it impossible for the IDE to guess. The only IDE-pragmatic solution is to have a distinct file extension for statically compiled Groovy files (say, .sgroovy instead of .groovy). So far this has been ruled out, but I think it's the most pragmatic, and IDE friendly, solution.



2016-06-21 18:37 GMT+02:00 Mr Andersson <[hidden email]>:


On 06/21/2016 02:38 PM, Winnebeck, Jason wrote:

Tying Cédric’s advice to your previous question about gmavenplus and joint compilation, per https://github.com/groovy/GMavenPlus/wiki/Examples#configuration-script you add the configuration tag with a reference to your groovy script.

I also mentioned that I could not get Gmavenplus to work, but maybe i did something wrong. But I literally copied and pasted that section.

 

Actually about 90+% of our code base in Groovy is CompileStatic I wonder if we should use that. Cédric, if we use the config script method, is it still possible to use the “skip” annotation to switch back to dynamic mode? Even if it worked, I highly doubt IntelliJ IDEA would know about it and think all files are dynamic typing so probably it’s still best for us to add @CompileStatic everywhere, but sometimes we forget where we wanted it. The performance difference is extreme when we forget it, on a certain class we missed recently it took our page rendering times from about 4ms to 52ms, so for us it’s an actual “bug” to forget to add @CompileStatic.


The problem with  the ANT task is that I don't think I can set classpath argumetns to the actual so passing the config location is a problem that needs be resolved. Not that easy with maven.

Groovy should instead provide a default GroovyStatic-2.4.4.jar file that enables this by default. That way everybody wins, and Groovy could join the club of static languages and not get rejected by those that needs to get Groovy.

It is also messy to set up config files for every maven module, although I am not sure. The code in that config file is also not dynamic.

withConfig(configuration) { ast(groovy.transform.CompileStatic) } and a simple option -compileStatic that uses an internal version of that file is preferable and SIMPLER.
groovyc -configscript src/conf/config.groovy src/main/groovy/MyClass.groovy
Is not needed here.


 

Jason

 

From: Cédric Champeau [[hidden email]]
Sent: Tuesday, June 21, 2016 8:29 AM
To: [hidden email]
Subject: Re: Is it possible to enable CompileStatic for an entire project

 

 

2016-06-21 14:24 GMT+02:00 Mr Andersson <[hidden email]>:

Is it possible to enable CompileStatic for an entire project?

Or do you have to do it on a per class basis?

I like Groovy for some of it's features, and mostly for it's close to Java syntax but I would really like it to be a static language.

I've heard about Groovy++ but I believe that's dead by now, no?

Question is wether you can tell the Groovy compiler with a flag to treat all Groovy classes on certain paths as static?

Preferable doable from ANT too.

 


This email message and any attachments are for the sole use of the intended recipient(s). Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message and any attachments.


1234 ... 6