

ES6 Generators Deliver Go Style Concurrency in JavaScript - llambda
http://swannodette.github.io/2013/08/24/es6-generators-and-csp

======
programminggeek
This is not exactly the same as go's concurrency insomuch as Go allows its
concurrency to be across multiple threads/processors and as far as I know node
runs on a single thread.

~~~
jamesjporter
Sure, but it provides similar concurrency _semantics_ (putting things on and
taking things off of channels), which is what I think David is really trying
to emphasize.

~~~
malandrew
Does that mean that this could pave the way to automatic spawning of web
workers or spawning of child processes (via future native language or engine
implementation or library)?

~~~
pfraze
To a limited capacity. If you're looking for:

    
    
      console.log('this is in the document');
      go(function() { console.log('this is in a web worker'); });
    

I'd recommend against it. Even if you can toString() the function passed to
go() and load that into a worker, you'd not carry the function's closure,
which I think is too complex.

    
    
      var x = 5;
      go(function() { console.log('x = '+x); });
      // => x = undefined
    

Could be done, but I'd rather stick with paradigms that fit the language more
closely.

