Re: async/await - is future reserved words in PHP 7.x?
| From: | Stephen Coakley | Date: | Thu, 01 Oct 2015 07:07:52 +0000 |
| Subject: | Re: async/await - is future reserved words in PHP 7.x? | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-88595@lists.php.net to get a copy of this message | ||
On 09/29/2015 01:04 PM, S.A.N wrote:
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.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
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