Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88595 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 78889 invoked from network); 1 Oct 2015 07:07:57 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Oct 2015 07:07:57 -0000 X-Host-Fingerprint: 68.118.157.39 68-118-157-39.dhcp.mdsn.wi.charter.com Received: from [68.118.157.39] ([68.118.157.39:18199] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 55/71-04700-BCBDC065 for ; Thu, 01 Oct 2015 03:07:55 -0400 Message-ID: <55.71.04700.BCBDC065@pb1.pair.com> To: internals@lists.php.net References: <56095A0C.4070306@cubiclesoft.com> <1443529244.15520.67.camel@kuechenschabe> <560AACB6.9080909@cubiclesoft.com> <09A2B2D4-EAE9-46E8-AF5C-4E83C4F3D8A2@icicle.io> Date: Thu, 1 Oct 2015 02:07:52 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Posted-By: 68.118.157.39 Subject: Re: [PHP-DEV] async/await - is future reserved words in PHP 7.x? From: me@stephencoakley.com (Stephen Coakley) 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