About actor syntax for Groovy 3

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

About actor syntax for Groovy 3

Daniel Sun
Hi all,

      As we all know, GPars is awesome in concurrency programming. How about introducing a new syntax for GPars's actor(http://www.gpars.org/guide/guide/actors.html) to support concurrency programming better like Erlang and Scala(https://rocketeer.be/articles/concurrency-in-erlang-scala/)? We can use <- to indicate sending messages(Erlang and Scala uses !). The initial idea is shown as follows:

// groovy.actor.Actor extends groovyx.gpars.actor.DefaultActor
class Counter extends groovy.actor.Actor {
    int counter = 0;

    void act() {
        react { int num ->
              ...
        }
    }
}

class ActorTest  {
    def counter = new Counter()
    counter.start()

    for (i in 0 .. 100000) {
        counter <- i    // send message to the counter actor
    }
}

       Any thoughts?
     
Cheers,
Daniel.Sun
Reply | Threaded
Open this post in threaded view
|

Re: About actor syntax for Groovy 3

Daniel Sun
class ActorTest  {
    def counter = new Counter()
    counter.start()

    for (i in 0 .. 100000) {
        counter <- i    // send message to the counter actor
    }
}

should be modified as:

class ActorTest  {
    public static void main(String[] args) {
        def counter = new Counter()
        counter.start()

        for (i in 0 .. 100000) {
          counter <- i    // send message to the counter actor
        }
    }
}
Reply | Threaded
Open this post in threaded view
|

Re: About actor syntax for Groovy 3

Andres Almiray
This is a slippery slope IMHO.

Adding custom syntax support in core for GPars might sound like a good idea given the fact that GPars is bundled with core. OTOH what about Spock, Grails, Ratpack and others? Wouldn't they benefit from custom syntax too? probably yes. Are they bundled with core? no, and they shouldn't.

My recommendation would be to prototype an AST transformation that can support the syntax, just like Spock does it.

One more thing, I would be very sad to see Groovy become a pale shade of Scala. Custom syntax and new operators are pushing Groovy in that direction.

Cheers
Andres

Sent from my primitive Tricorder

> On Jan 7, 2017, at 6:21 PM, Daniel Sun <[hidden email]> wrote:
>
> class ActorTest  {
>    def counter = new Counter()
>    counter.start()
>
>    for (i in 0 .. 100000) {
>        counter <- i    // send message to the counter actor
>    }
> }
>
> should be modified as:
>
> class ActorTest  {
>    public static void main(String[] args) {
>        def counter = new Counter()
>        counter.start()
>
>        for (i in 0 .. 100000) {
>          counter <- i    // send message to the counter actor
>        }
>    }
> }
>
>
>
> --
> View this message in context: http://groovy.329449.n5.nabble.com/About-actor-syntax-for-Groovy-3-tp5737574p5737575.html
> Sent from the Groovy Dev mailing list archive at Nabble.com.
Reply | Threaded
Open this post in threaded view
|

Re: About actor syntax for Groovy 3

Jesper Steen Møller
In reply to this post by Daniel Sun
But

Wouldn’t << be a natural choice which would work today?

-Jesper

> On 7 Jan 2017, at 18.16, Daniel Sun <[hidden email]> wrote:
>
> Hi all,
>
>      As we all know, GPars is awesome in concurrency programming. How about
> introducing a new syntax for GPars's
> actor(http://www.gpars.org/guide/guide/actors.html) to support concurrency
> programming better like Erlang and
> Scala(https://rocketeer.be/articles/concurrency-in-erlang-scala/)? We can
> use <- to indicate sending messages(Erlang and Scala uses !). The initial
> idea is shown as follows:
>
> // groovy.actor.Actor extends groovyx.gpars.actor.DefaultActor
> class Counter extends groovy.actor.Actor {
>    int counter = 0;
>
>    void act() {
>        react { int num ->
>              ...
>        }
>    }
> }
>
> class ActorTest  {
>    def counter = new Counter()
>    counter.start()
>
>    for (i in 0 .. 100000) {
>        counter <- i    // send message to the counter actor
>    }
> }
>
>       Any thoughts?
>
> Cheers,
> Daniel.Sun
>
>
>
> --
> View this message in context: http://groovy.329449.n5.nabble.com/About-actor-syntax-for-Groovy-3-tp5737574.html
> Sent from the Groovy Dev mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: About actor syntax for Groovy 3

jnorthr
In reply to this post by Andres Almiray
Russel is working on GPars v2.0 so have asked him if this proposed change is do-able.

On 7 January 2017 at 18:28, Andres Almiray <[hidden email]> wrote:
This is a slippery slope IMHO.

Adding custom syntax support in core for GPars might sound like a good idea given the fact that GPars is bundled with core. OTOH what about Spock, Grails, Ratpack and others? Wouldn't they benefit from custom syntax too? probably yes. Are they bundled with core? no, and they shouldn't.

My recommendation would be to prototype an AST transformation that can support the syntax, just like Spock does it.

One more thing, I would be very sad to see Groovy become a pale shade of Scala. Custom syntax and new operators are pushing Groovy in that direction.

Cheers
Andres

Sent from my primitive Tricorder

> On Jan 7, 2017, at 6:21 PM, Daniel Sun <[hidden email]> wrote:
>
> class ActorTest  {
>    def counter = new Counter()
>    counter.start()
>
>    for (i in 0 .. 100000) {
>        counter <- i    // send message to the counter actor
>    }
> }
>
> should be modified as:
>
> class ActorTest  {
>    public static void main(String[] args) {
>        def counter = new Counter()
>        counter.start()
>
>        for (i in 0 .. 100000) {
>          counter <- i    // send message to the counter actor
>        }
>    }
> }
>
>
>
> --
> View this message in context: http://groovy.329449.n5.nabble.com/About-actor-syntax-for-Groovy-3-tp5737574p5737575.html
> Sent from the Groovy Dev mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: About actor syntax for Groovy 3

jnorthr
In reply to this post by Jesper Steen Møller
a nice idea ;-D


On 7 January 2017 at 18:30, Jesper Steen Møller <[hidden email]> wrote:
But

Wouldn’t << be a natural choice which would work today?

-Jesper

> On 7 Jan 2017, at 18.16, Daniel Sun <[hidden email]> wrote:
>
> Hi all,
>
>      As we all know, GPars is awesome in concurrency programming. How about
> introducing a new syntax for GPars's
> actor(http://www.gpars.org/guide/guide/actors.html) to support concurrency
> programming better like Erlang and
> Scala(https://rocketeer.be/articles/concurrency-in-erlang-scala/)? We can
> use <- to indicate sending messages(Erlang and Scala uses !). The initial
> idea is shown as follows:
>
> // groovy.actor.Actor extends groovyx.gpars.actor.DefaultActor
> class Counter extends groovy.actor.Actor {
>    int counter = 0;
>
>    void act() {
>        react { int num ->
>              ...
>        }
>    }
> }
>
> class ActorTest  {
>    def counter = new Counter()
>    counter.start()
>
>    for (i in 0 .. 100000) {
>        counter <- i    // send message to the counter actor
>    }
> }
>
>       Any thoughts?
>
> Cheers,
> Daniel.Sun
>
>
>
> --
> View this message in context: http://groovy.329449.n5.nabble.com/About-actor-syntax-for-Groovy-3-tp5737574.html
> Sent from the Groovy Dev mailing list archive at Nabble.com.


Reply | Threaded
Open this post in threaded view
|

Re: About actor syntax for Groovy 3

jnorthr
In reply to this post by Jesper Steen Møller
Have found this Actor slideshow that may help us a bit ? http://www.slideshare.net/drorbr/the-actor-model-towards-better-concurrency


On 7 January 2017 at 18:30, Jesper Steen Møller <[hidden email]> wrote:
But

Wouldn’t << be a natural choice which would work today?

-Jesper

> On 7 Jan 2017, at 18.16, Daniel Sun <[hidden email]> wrote:
>
> Hi all,
>
>      As we all know, GPars is awesome in concurrency programming. How about
> introducing a new syntax for GPars's
> actor(http://www.gpars.org/guide/guide/actors.html) to support concurrency
> programming better like Erlang and
> Scala(https://rocketeer.be/articles/concurrency-in-erlang-scala/)? We can
> use <- to indicate sending messages(Erlang and Scala uses !). The initial
> idea is shown as follows:
>
> // groovy.actor.Actor extends groovyx.gpars.actor.DefaultActor
> class Counter extends groovy.actor.Actor {
>    int counter = 0;
>
>    void act() {
>        react { int num ->
>              ...
>        }
>    }
> }
>
> class ActorTest  {
>    def counter = new Counter()
>    counter.start()
>
>    for (i in 0 .. 100000) {
>        counter <- i    // send message to the counter actor
>    }
> }
>
>       Any thoughts?
>
> Cheers,
> Daniel.Sun
>
>
>
> --
> View this message in context: http://groovy.329449.n5.nabble.com/About-actor-syntax-for-Groovy-3-tp5737574.html
> Sent from the Groovy Dev mailing list archive at Nabble.com.


Reply | Threaded
Open this post in threaded view
|

Re: About actor syntax for Groovy 3

Daniel Sun
In reply to this post by Andres Almiray
Hi Andres,

      If Scala was the sun, I wish Groovy was an eclipse ;)

      Maybe adding custom syntax for actor is not good idea for a programming language. But as a programming language, Groovy should learn good things from others to keep evolving and competitiveness. (like C# and Java)

Cheers,
Daniel.Sun



在 "Andres Almiray [via Groovy]" <ml-node+[hidden email]>,2017年1月8日 上午1:28写道:

This is a slippery slope IMHO.

Adding custom syntax support in core for GPars might sound like a good idea given the fact that GPars is bundled with core. OTOH what about Spock, Grails, Ratpack and others? Wouldn't they benefit from custom syntax too? probably yes. Are they bundled with core? no, and they shouldn't.

My recommendation would be to prototype an AST transformation that can support the syntax, just like Spock does it.

One more thing, I would be very sad to see Groovy become a pale shade of Scala. Custom syntax and new operators are pushing Groovy in that direction.

Cheers
Andres

Sent from my primitive Tricorder

> On Jan 7, 2017, at 6:21 PM, Daniel Sun <[hidden email]> wrote:
>
> class ActorTest  {
>    def counter = new Counter()
>    counter.start()
>
>    for (i in 0 .. 100000) {
>        counter <- i    // send message to the counter actor
>    }
> }
>
> should be modified as:
>
> class ActorTest  {
>    public static void main(String[] args) {
>        def counter = new Counter()
>        counter.start()
>
>        for (i in 0 .. 100000) {
>          counter <- i    // send message to the counter actor
>        }
>    }
> }
>
>
>
> --
> View this message in context: http://groovy.329449.n5.nabble.com/About-actor-syntax-for-Groovy-3-tp5737574p5737575.html
> Sent from the Groovy Dev mailing list archive at Nabble.com.



If you reply to this email, your message will be added to the discussion below:
http://groovy.329449.n5.nabble.com/About-actor-syntax-for-Groovy-3-tp5737574p5737576.html
To unsubscribe from About actor syntax for Groovy 3, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: About actor syntax for Groovy 3

Daniel Sun
In reply to this post by Jesper Steen Møller
Yeah, << is a better choice ;)



在 Jesper Steen Møller [via Groovy] <ml-node+[hidden email]>,2017年1月8日 上午1:31写道:

But

Wouldn’t << be a natural choice which would work today?

-Jesper

> On 7 Jan 2017, at 18.16, Daniel Sun <[hidden email]> wrote:
>
> Hi all,
>
>      As we all know, GPars is awesome in concurrency programming. How about
> introducing a new syntax for GPars's
> actor(http://www.gpars.org/guide/guide/actors.html) to support concurrency
> programming better like Erlang and
> Scala(https://rocketeer.be/articles/concurrency-in-erlang-scala/)? We can
> use <- to indicate sending messages(Erlang and Scala uses !). The initial
> idea is shown as follows:
>
> // groovy.actor.Actor extends groovyx.gpars.actor.DefaultActor
> class Counter extends groovy.actor.Actor {
>    int counter = 0;
>
>    void act() {
>        react { int num ->
>              ...
>        }
>    }
> }
>
> class ActorTest  {
>    def counter = new Counter()
>    counter.start()
>
>    for (i in 0 .. 100000) {
>        counter <- i    // send message to the counter actor
>    }
> }
>
>       Any thoughts?
>
> Cheers,
> Daniel.Sun
>
>
>
> --
> View this message in context: http://groovy.329449.n5.nabble.com/About-actor-syntax-for-Groovy-3-tp5737574.html
> Sent from the Groovy Dev mailing list archive at Nabble.com.




If you reply to this email, your message will be added to the discussion below:
http://groovy.329449.n5.nabble.com/About-actor-syntax-for-Groovy-3-tp5737574p5737577.html
To unsubscribe from About actor syntax for Groovy 3, click here.
NAML
Reply | Threaded
Open this post in threaded view
|

Re: About actor syntax for Groovy 3

Daniel Sun
In reply to this post by jnorthr
As Andres pointed, it is better for GPars to have its own DSL.

Cheers,
Daniel.Sun



在 "jnorthr [via Groovy]" <ml-node+[hidden email]>,2017年1月8日 上午1:35写道:

Russel is working on GPars v2.0 so have asked him if this proposed change is do-able.

On 7 January 2017 at 18:28, Andres Almiray <[hidden email]> wrote:
This is a slippery slope IMHO.

Adding custom syntax support in core for GPars might sound like a good idea given the fact that GPars is bundled with core. OTOH what about Spock, Grails, Ratpack and others? Wouldn't they benefit from custom syntax too? probably yes. Are they bundled with core? no, and they shouldn't.

My recommendation would be to prototype an AST transformation that can support the syntax, just like Spock does it.

One more thing, I would be very sad to see Groovy become a pale shade of Scala. Custom syntax and new operators are pushing Groovy in that direction.

Cheers
Andres

Sent from my primitive Tricorder

> On Jan 7, 2017, at 6:21 PM, Daniel Sun <[hidden email]> wrote:
>
> class ActorTest  {
>    def counter = new Counter()
>    counter.start()
>
>    for (i in 0 .. 100000) {
>        counter <- i    // send message to the counter actor
>    }
> }
>
> should be modified as:
>
> class ActorTest  {
>    public static void main(String[] args) {
>        def counter = new Counter()
>        counter.start()
>
>        for (i in 0 .. 100000) {
>          counter <- i    // send message to the counter actor
>        }
>    }
> }
>
>
>
> --
> View this message in context: http://groovy.329449.n5.nabble.com/About-actor-syntax-for-Groovy-3-tp5737574p5737575.html
> Sent from the Groovy Dev mailing list archive at Nabble.com.




If you reply to this email, your message will be added to the discussion below:
http://groovy.329449.n5.nabble.com/About-actor-syntax-for-Groovy-3-tp5737574p5737578.html
To unsubscribe from About actor syntax for Groovy 3, click here.
NAML
12