

V8 developers start working on ES6 generators for JavaScript - jlongster
http://code.google.com/p/v8/issues/detail?id=2355

======
jlongster
Note the opportunity here: all your promises code immediately turns into this:
<http://taskjs.org/>

~~~
recuter
JS next seems almost as if they turned Javascript into Python. I am pleased.

~~~
cpprototypes
I wish V8 already had generators back when node.js started. It would've been a
true solution to callback hell. There's libraries like async to help with
that, but it's not as good as something like tasks.js could be.

~~~
recuter
But on the other hand Twisted is not a panacea either, not that this is a
perfect parallel or anything. But I agree, this is definitely a step in the
right direction.

I wonder if it will be feasible to code in JS Next and have a compiler step
somehow take care of backporting. Probably not.

------
jlongster
Andy Wingo mentioned via twitter that he's working on it:
<https://twitter.com/andywingo/status/316644148532891648>

~~~
apaprocki
Bloomberg is sponsoring Igalia (Andy) to implement ES6 generators in V8 :)

------
Yoric
Ahaha, finally!

I have been waiting to use this feature on the web, well, since Mozilla
implemented it, which must have been at least 5 years ago.

~~~
firefoxman1
Why didn't ecma just use Mozilla's implementation?

~~~
lucian1900
The spec is quite closely modelled after Mozilla's implementation, yes. Other
engines just neglected to implement it.

~~~
_jmar777
> Other engines just neglected to implement it.

Why would they have? Seems like waiting for ecma approval and specification
makes sense.

~~~
lucian1900
Sure, I didn't mean they did something wrong.

Although it is quite obviously a good idea :)

------
olegp
In the mean time you can use fibers with Node. I've been using them for
StartHQ (<http://starthq.com>) via Common Node
(<https://github.com/olegp/common-node>) and to be honest I don't see how I
could have made it maintainable with promises, let alone no flow control
library at all.

~~~
_alex4nder
Agreed. Fibers are a great way to take simple synchronous-looking code and
make it play well with the rest of node, without resorting to threads.

------
Mahn
A bit offtopic, but: are all chromium & V8 team members Googlers? just
wondering, chromium and V8 are both open source, but I've never head of any
major contributors other than Google itself.

~~~
evilpie
From what I gathered (ie. talking to mraleph) v8 is mostly just Google
employees. I can't speak about Chromium. The contributor situation is not
vastly different for SpiderMonkey or JSC. I am usually the only contributor,
besides 1-3 others that sometimes work on SpiderMonkey.

Edit: I think some ports are maintained from people outside Google. It's not
really easy to tell, because most people have @chromium addresses.

~~~
mraleph
MIPS port is fully maintained by MIPS people. These days they even have commit
rights.

You can see full list of people and organizations that contributed to V8 in
the AUTHORS file.

------
gbadman
I've been really looking forward to this ever since I saw this post[1] on the
possibilities that coroutines introduce for async programming.

This article in question was already discussed in some depth on HN[2].

Can't wait for an era of much more elegant async code!

[1] <http://syzygy.st/javascript-coroutines/>

[2] <https://news.ycombinator.com/item?id=4912413>

------
surrealize
The es wiki page linked in the bug doesn't say much about array/generator
comprehensions, e.g.:

[for (x of a) for (y of b) x * y]

but those would be really nice as well.

A few months ago the ES committee decided to switch them from reading right-
to-left (as in spidermonkey comprehensions, python, and haskell) to reading
left-to-right (as in C#):

<https://gist.github.com/dherman/b250d1fad15dbb5f77a5>

------
ajuc
I'd love to use this for cooperative multitasking inside one thread (like in
Python example using yield). Would be great for simple scripts for ai in
games.

------
domenicd
So who do we have to pay to get this turned on by default, instead of behind a
flag?

------
TazeTSchnitzel
PHP gets yield, now JS too?

You'd think it would be the other way round!

