Re: [VOTE] Fibers

From: Date: Thu, 11 Mar 2021 15:42:24 +0000
Subject: Re: [VOTE] Fibers
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-113476@lists.php.net to get a copy of this message


> On Mar 11, 2021, at 7:56 AM, 韩天峰 <rango@swoole.com> wrote:
> 
> Hi,
> I am come from Chinese, we may have some cultural differences, and there may be some
> difficulties in communication. I try to express my opinion.
> To be precise, the fiber can only be used for amphp and reactphp or other event-driven
> asynchronous IO frameworks developed using php. The RFC does not mention how an extension uses
> fiber.
> Fiber is not like threads or processes of operating system. It is not parallel, nor is it
> concurrent. This requires an event-driven scheduler to have practical value. Currently php does not
> have event-driven support. So normal web developers don’t know how to use fiber. It is for
> developers of asynchronous io programming. 
> I just suggest first to provide a PECL extension like ext-event/ext-libevent, no need to be
> integrated into php now. Swoole is also provided to users as a PECL extension.
> 

Hello,

I agree that this feature is targeted at libraries wishing to provide better async I/O. What I
disagree with is that this means it should not be a part of PHP.

Whether many developers realize it or not, several commonly used libraries already contain some
async I/O features, often implemented with promises, which have some API trade-offs to attempt to
integrate async into typical synchronous code. Guzzle, Symfony, and Psalm are three commonly used
libraries that have asynchronous APIs available.

Having fibers available in core will allow these libraries to offer async code with an improved,
more intuitive API as well as expand their use of async I/O beyond what it typically has been used
for, HTTP requests, to include databases, redis, file access, etc.

An event scheduler is needed for async I/O to work, but several implementations already exist in
user space and work very well with fibers, as I and ReactPHP team can attest. Fibers are the key to
integrating these event schedulers into the greater PHP community.

Swoole provides an entire large, opinionated framework for async coding. That’s fantastic!
However, it is not a flexible tool that any library can use for a variety of purposes. It is more
akin to choosing a framework such as Laravel or Yii to write your PHP app.

Event-driven programming is desperately needed in the PHP community. Right now PHP contains nearly
all the tools for fantastic, clear, intuitive user space async code. This is the one missing piece.

Aaron Piotrowski


Thread (71 messages)

« previous php.internals (#113476) next »