On Thu, Oct 3, 2019 at 8:40 AM JuciÊ Andrade <oju...@gmail.com> wrote:
>
> On Thursday, October 3, 2019 at 10:47:27 AM UTC-3, burak serdar wrote:
>>
>> On Thu, Oct 3, 2019 at 6:18 AM JuciÊ Andrade <oju...@gmail.com> wrote:
>> > I use channels exactly that way and they work pretty well.
>>
>> Then you're paying some penalty for synchronization where the same
>> thing can be achieved without that penalty.
>>
>
> Yes, indeed, but channels offer some significant advantages:
>
> 1. a division of labor between several goroutines is made possible without 
> much effort. That can mean a lot, depending on how much complex is the logic 
> involved in generating each value;

When there are multiple goroutines involved, you have to use channels.

> 2. a possibly very complex state is preserved between each generated value 
> (the execution stack);

This I disagree. A list achieves the same purpose without
synchronization overhead.

>
> I would dare to say that a prime number generator is more of an exception, 
> because the state to be preserved between calls is well understood. Now think 
> about some evolving code, where you can't know beforehand how complex that 
> will be some years from now. Channels are a safer bet.

Honestly, I don't understand this argument. Complexity of sequential
code has got nothing to do with concurrent behavior. If there is no
concurrency, then there is no need to use channels.

>
> Anyway, you are correct: each use must be evaluated in it's pros an cons. You 
> will see that in the vast majority of cases channels performance is more than 
> enough.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to golang-nuts+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/golang-nuts/eb84a84c-be8d-4b81-8c5c-33cb09b70168%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAMV2RqrD6U8giuDp0WSNr6Yqtwq7K6JO9J4rqVtKTgtXKC4Ehg%40mail.gmail.com.

Reply via email to