Groovy 3 lambda, method reference, default methods

classic Classic list List threaded Threaded
12 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Groovy 3 lambda, method reference, default methods

Winnebeck, Jason
I took a look at the new Groovy 3 changes at http://groovy-lang.org/releasenotes/groovy-3.0.html and noticed there is still a question as to whether or not to implement lambdas, method references, and default methods as closures and traits. Is the Groovy team still taking feedback on these decisions?

If so, my vote would be to by default, emit JDK8+ "native" implementations wherever possible. I would even go as far to say to allow Groovy 3 to emit JDK8+ lambdas for any expression where a closure inline to a method taking a SAM, as a way to improve Groovy 2 code, but I can understand why it might be better to be consistent and have closure blocks always generate closures (as closures have delegate concept that extends Java lambdas).

The reason for my vote is I work on a large Groovy project where performance is a significant consideration. My experience so far is that using closures with streams has poor performance such that any time I want to use streams I either write the class in Java or I make a utility class with the Streams code and call that utility class from Groovy. It is unfortunate that JDK 8's enhancements make Groovy feel a lot less necessary to me, especially since I learned how hard it is to avoid BigDecimal math even when using CompileStatic. We are working with a business rules system and sometimes a single rule can trigger 1k+ times within a single page refresh, so we have to pay attention to which Groovy features we use in certain rules. Avoiding closures, using for in preference to .each, etc., can result in order of magnitude speedup. That's why my vote is to have Groovy compile static generate code as close to Java as possible, whenever a choice is possible.

Jason Winnebeck

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: Groovy 3 lambda, method reference, default methods

Daniel.Sun
Up to now native lambda is available under compile static mode in
3.0.0-alpha-2(will be released soon) and 2.6.0-alpha-3(Parrot parser is
required enabled and using Java8+).

Cheers,
Daniel.Sun



--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Users-f329450.html
Daniel Sun
Apache Groovy committer

Blog: http://blog.sunlan.me
Twitter: @daniel_sun
Reply | Threaded
Open this post in threaded view
|

RE: Groovy 3 lambda, method reference, default methods

Winnebeck, Jason
This is major news, if the performance is comparable to Java. So with 2.6.0-alpha-3, Parrot, and JDK8+ you can use lambda expressions in static groovy and have them compiled to native lambda, or is it using closure syntax?

Is there then a major difference in language between 2.6+Parrot and 3.0?

I wonder if the IntelliJ support ticket should be updated to say support new language features in Groovy 2.6 as well?

Jason

-----Original Message-----
From: Daniel.Sun [mailto:[hidden email]]
Sent: Wednesday, March 21, 2018 11:50 AM
To: [hidden email]
Subject: Re: Groovy 3 lambda, method reference, default methods

Up to now native lambda is available under compile static mode in 3.0.0-alpha-2(will be released soon) and 2.6.0-alpha-3(Parrot parser is required enabled and using Java8+).

Cheers,
Daniel.Sun



--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Users-f329450.html

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: Groovy 3 lambda, method reference, default methods

Daniel.Sun
You can write Java8 style code(e.g. lambda, method/constructor reference,
etc.) when Parrot parser is enabled :-)
See https://github.com/danielsun1106/groovy-parser


> Is there then a major difference in language between 2.6+Parrot and 3.0?

3.0 enables Parrot parser by default, so no differences.


> I wonder if the IntelliJ support ticket should be updated to say support
> new language features in Groovy 2.6 as well?

I see the title contains "Groovy 3", so I am not sure if it will support 2.6


Cheers,
Daniel.Sun




--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Users-f329450.html
Daniel Sun
Apache Groovy committer

Blog: http://blog.sunlan.me
Twitter: @daniel_sun
Reply | Threaded
Open this post in threaded view
|

RE: Groovy 3 lambda, method reference, default methods

Winnebeck, Jason
That's cool that it's basically a separate project. I wonder if IntelliJ itself can use the Parrot parser then to parse Groovy code, in that case it would always be guaranteed to be 100% "compatible", at least from a syntax perspective. I bet same concept could apply to code analysis tools.

Jason

-----Original Message-----
From: Daniel.Sun [mailto:[hidden email]]
Sent: Wednesday, March 21, 2018 12:11 PM
To: [hidden email]
Subject: RE: Groovy 3 lambda, method reference, default methods

You can write Java8 style code(e.g. lambda, method/constructor reference,
etc.) when Parrot parser is enabled :-)
See https://github.com/danielsun1106/groovy-parser


> Is there then a major difference in language between 2.6+Parrot and 3.0?

3.0 enables Parrot parser by default, so no differences.


> I wonder if the IntelliJ support ticket should be updated to say
> support new language features in Groovy 2.6 as well?

I see the title contains "Groovy 3", so I am not sure if it will support 2.6


Cheers,
Daniel.Sun




--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Users-f329450.html

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.
MG
Reply | Threaded
Open this post in threaded view
|

RE: Groovy 3 lambda, method reference, default methods

MG
In reply to this post by Daniel.Sun
I guess the Groovy 3.0/3.0-- (aka 2.6) syntax elements support will be switchable in IntelliJ, anything else would make little sense to me.
But we have the expert on this mailing list, who should be able to tell us... :-)
mg

-------- Ursprüngliche Nachricht --------
Von: "Daniel.Sun" <[hidden email]>
Datum: 21.03.18 17:10 (GMT+01:00)
Betreff: RE: Groovy 3 lambda, method reference, default methods

You can write Java8 style code(e.g. lambda, method/constructor reference,
etc.) when Parrot parser is enabled :-)
See https://github.com/danielsun1106/groovy-parser


> Is there then a major difference in language between 2.6+Parrot and 3.0?

3.0 enables Parrot parser by default, so no differences.


> I wonder if the IntelliJ support ticket should be updated to say support
> new language features in Groovy 2.6 as well?

I see the title contains "Groovy 3", so I am not sure if it will support 2.6


Cheers,
Daniel.Sun




--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Users-f329450.html
MG
Reply | Threaded
Open this post in threaded view
|

RE: Groovy 3 lambda, method reference, default methods

MG
In reply to this post by Daniel.Sun
I guess the Groovy 3.0/3.0-- (aka 2.6) syntax elements support will be switchable in IntelliJ, anything else would make little sense to me.
But we have the expert on this mailing list, who should be able to tell us... :-)
mg

-------- Ursprüngliche Nachricht --------
Von: "Daniel.Sun" <[hidden email]>
Datum: 21.03.18 17:10 (GMT+01:00)
Betreff: RE: Groovy 3 lambda, method reference, default methods

You can write Java8 style code(e.g. lambda, method/constructor reference,
etc.) when Parrot parser is enabled :-)
See https://github.com/danielsun1106/groovy-parser


> Is there then a major difference in language between 2.6+Parrot and 3.0?

3.0 enables Parrot parser by default, so no differences.


> I wonder if the IntelliJ support ticket should be updated to say support
> new language features in Groovy 2.6 as well?

I see the title contains "Groovy 3", so I am not sure if it will support 2.6


Cheers,
Daniel.Sun




--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Users-f329450.html
Reply | Threaded
Open this post in threaded view
|

Re: Groovy 3 lambda, method reference, default methods

daniil.ovchinnikov
In reply to this post by Winnebeck, Jason
IntelliJ will support Groovy 3 but with own parser.

- using the parser provided by Groovy library restricts support to that library version;
- compiler parsers are usually non-recoverable, but in IntelliJ we want to provide ability to work with broken code as much as possible, so we have own parsers for (almost) each language.



Daniil Ovchinnikov
Software Developer
JetBrains
jetbrains.com
“Drive to develop”



> On 21 Mar 2018, at 22:30, mg <[hidden email]> wrote:
>
> I guess the Groovy 3.0/3.0-- (aka 2.6) syntax elements support will be switchable in IntelliJ, anything else would make little sense to me.
> But we have the expert on this mailing list, who should be able to tell us... :-)
> mg
>
> -------- Ursprüngliche Nachricht --------
> Von: "Daniel.Sun" <[hidden email]>
> Datum: 21.03.18 17:10 (GMT+01:00)
> An: [hidden email]
> Betreff: RE: Groovy 3 lambda, method reference, default methods
>
> You can write Java8 style code(e.g. lambda, method/constructor reference,
> etc.) when Parrot parser is enabled :-)
> See https://github.com/danielsun1106/groovy-parser
>
>
> > Is there then a major difference in language between 2.6+Parrot and 3.0?
>
> 3.0 enables Parrot parser by default, so no differences.
>
>
> > I wonder if the IntelliJ support ticket should be updated to say support
> > new language features in Groovy 2.6 as well?
>
> I see the title contains "Groovy 3", so I am not sure if it will support 2.6
>
>
> Cheers,
> Daniel.Sun
>
>
>
>
> --
> Sent from: http://groovy.329449.n5.nabble.com/Groovy-Users-f329450.html

MG
Reply | Threaded
Open this post in threaded view
|

Re: Groovy 3 lambda, method reference, default methods

MG
Will Groovy 3.0 feature support be configurable (as for Java), or will it be deduced from Groovy libs used, ... ?

-------- Ursprüngliche Nachricht --------
Von: Daniil Ovchinnikov <[hidden email]>
Datum: 22.03.18 12:41 (GMT+01:00)
Betreff: Re: Groovy 3 lambda, method reference, default methods

IntelliJ will support Groovy 3 but with own parser.

- using the parser provided by Groovy library restricts support to that library version;
- compiler parsers are usually non-recoverable, but in IntelliJ we want to provide ability to work with broken code as much as possible, so we have own parsers for (almost) each language.



Daniil Ovchinnikov
Software Developer
JetBrains
jetbrains.com
“Drive to develop”



> On 21 Mar 2018, at 22:30, mg <[hidden email]> wrote:
>
> I guess the Groovy 3.0/3.0-- (aka 2.6) syntax elements support will be switchable in IntelliJ, anything else would make little sense to me.
> But we have the expert on this mailing list, who should be able to tell us... :-)
> mg
>
> -------- Ursprüngliche Nachricht --------
> Von: "Daniel.Sun" <[hidden email]>
> Datum: 21.03.18 17:10 (GMT+01:00)
> An: [hidden email]
> Betreff: RE: Groovy 3 lambda, method reference, default methods
>
> You can write Java8 style code(e.g. lambda, method/constructor reference,
> etc.) when Parrot parser is enabled :-)
> See https://github.com/danielsun1106/groovy-parser
>
>
> > Is there then a major difference in language between 2.6+Parrot and 3.0?
>
> 3.0 enables Parrot parser by default, so no differences.
>
>
> > I wonder if the IntelliJ support ticket should be updated to say support
> > new language features in Groovy 2.6 as well?
>
> I see the title contains "Groovy 3", so I am not sure if it will support 2.6
>
>
> Cheers,
> Daniel.Sun
>
>
>
>
> --
> Sent from: http://groovy.329449.n5.nabble.com/Groovy-Users-f329450.html

Reply | Threaded
Open this post in threaded view
|

Re: Groovy 3 lambda, method reference, default methods

daniil.ovchinnikov
In reply to this post by Winnebeck, Jason
It will be deduced it from library with a single switch to use Parrot in 2.6.
There is no other reason not to use library version, since Groovy can’t cross compile classes to run with old Groovy versions.



Daniil Ovchinnikov
Software Developer
JetBrains
jetbrains.com
“Drive to develop”



On 22 Mar 2018, at 15:42, mg <[hidden email]> wrote:

Will Groovy 3.0 feature support be configurable (as for Java), or will it be deduced from Groovy libs used, ... ?

-------- Ursprüngliche Nachricht --------
Von: Daniil Ovchinnikov <[hidden email]>
Datum: 22.03.18 12:41 (GMT+01:00)
Betreff: Re: Groovy 3 lambda, method reference, default methods

IntelliJ will support Groovy 3 but with own parser.

- using the parser provided by Groovy library restricts support to that library version;
- compiler parsers are usually non-recoverable, but in IntelliJ we want to provide ability to work with broken code as much as possible, so we have own parsers for (almost) each language.



Daniil Ovchinnikov
Software Developer
JetBrains
jetbrains.com
“Drive to develop”



> On 21 Mar 2018, at 22:30, mg <[hidden email]> wrote:
>
> I guess the Groovy 3.0/3.0-- (aka 2.6) syntax elements support will be switchable in IntelliJ, anything else would make little sense to me.
> But we have the expert on this mailing list, who should be able to tell us... :-)
> mg
>
> -------- Ursprüngliche Nachricht --------
> Von: "Daniel.Sun" <[hidden email]>
> Datum: 21.03.18 17:10 (GMT+01:00)
> An: [hidden email]
> Betreff: RE: Groovy 3 lambda, method reference, default methods
>
> You can write Java8 style code(e.g. lambda, method/constructor reference,
> etc.) when Parrot parser is enabled :-)
> See https://github.com/danielsun1106/groovy-parser
>
>
> > Is there then a major difference in language between 2.6+Parrot and 3.0?
>
> 3.0 enables Parrot parser by default, so no differences.
>
>
> > I wonder if the IntelliJ support ticket should be updated to say support
> > new language features in Groovy 2.6 as well?
>
> I see the title contains "Groovy 3", so I am not sure if it will support 2.6
>
>
> Cheers,
> Daniel.Sun
>
>
>
>
> --
> Sent from: http://groovy.329449.n5.nabble.com/Groovy-Users-f329450.html


12