On 09/29/2015 01:04 PM, S.A.N wrote:
Implementing elegant, readable, and stable asynchronous code in userland PHP
code is very possible. In fact, I’ve done exactly this with Icicle
(https://github.com/icicleio/icicle). Icicle uses generators and promises to
implement coroutines. When a coroutine yields a promise, the coroutine is
interrupted until the promise resolves, sending or throwing the resolution
value into the generator. While a coroutine is interrupted, other code in the
program is given the chance to be executed. This behavior is similar to
async/await, instead using a generator as the async function and yield as
await. There are several packages available for Icicle that implement
non-blocking I/O and concurrency (multithreading). There are no extensions
required for Icicle and no black magic – just making good use of the tools
already available.
My experience says that callback, promise, yield, not transparent as
the async/await in С#.
In other languages:
Python - coroutines with async and await
https://www.python.org/dev/peps/pep-0492/
ECMAScript
https://github.com/lukehoban/ecmascript-asyncawait
Agreed, though in both languages, async / await started out by using
generators (yield) and futures (promises & callbacks). In JavaScript's
case, the implementation is actually still built on top of generators.
So, I'm confident we'll get there eventually.
When Node.js appear async/await, many developers and projects will
migrate to a Node.js, if PHP is not implement async APIs.
Hopefully, Dmitry Stogov and others, will make another surprise:
PHP-Next-Async? :)
OT: I don't have any numbers, but I'm not so sure as many people
"switched" to Node.js as people claim. Node.js has a similar, but
distinct, goal that is different from PHP's.
--
Stephen
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php