Subject: Re: Harmony - proxies | asynchronous
John J Barton
johnjbarton at johnjbarton.com
Fri Sep 2 16:15:56 PDT 2011
On Fri, Sep 2, 2011 at 3:48 PM, Brendan Eich <brendan at mozilla.com> wrote:
> On Sep 2, 2011, at 2:26 PM, John J Barton wrote:
> I'm pretty puzzled by this discussion and I'm guessing other folks might be
> puzzled as well. Since I understood node fibers as "thread for Node", the
> discussion I read is:
> /be: You can have threads!
> I did not say that. Remember, <http://brendaneich.com/2007/02/threads-suck/>
> t <http://brendaneich.com/2007/02/threads-suck/>hreads suck.
That's good news, thanks for clearing that much up.
> Generators are not threads. Generators are shallow one-shot
> continuations. They do not even imply an event loop turn per yield. But they
> are co-expressive with, and more primitive than, deferred/async functions
> (now that we have PEP-380 style return e; from generator body).
> With generators one can build up a variety of async libraries that do not
> require manual CPS conversion via the dreaded function-expression nest.
Ok I hope someone creates more tutorial information about generators. I read
about them and played around with some examples, but I did not come away
> Mikeal: We don't want threads!
> Again the issue is not threads. It is what idiom or keyword signals the
> reader that a voluntary suspension point has been reached and later or
> deeper-nested code runs in a different turn (or *may* run in a different
> Node.JS is a single-threaded server and always will be. No threads, not
> even cooperatively scheduled.
> If I'm on the right track, then I should understand how this relates to
> proxies. But I don't. Any hints?
> Proxies are handy for making promises have an API that looks like plain old
> object API. obj.foo instead of obj.get("foo"), etc.
Thanks, that's much clearer. So proxies are a generalization of getters.
As for the application, reasoning about code that looks like hash-table
lookup but acts very different may not be better than reasoning about code
that looks like spaghetti but acts like you expect.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss