Hello, Derick

I think there is a big misunderstanding of the situation here.

> But you approach this from the other side, by wanting to make PHP itself
> an asynchronous language

I think I come across as a reasonable person. I genuinely don’t
understand how such a conclusion could have been drawn, or based on
what.
So please allow me to briefly dive into the history of programming to
explain that I am of sound mind and in good mental health.

In the late 2000s, Ryan Dahl noticed a simple thing:
servers spend most of their time waiting: for the network, the disk, the client.
And yet we create threads just to sit idle.

He proposed a radical idea:
one thread, no blocking waits.
The code does not sleep, it postpones a thought and moves on.

That is how Node.js was born. An event loop and asynchronous code that
later took the form of async/await, essentially coroutines.

But computation does not know how to wait. Heavy work began to
suffocate the main thread.

The solution was simple and honest: let one thread wait and
orchestrate, and let heavy tasks move to workers.
Thus a clear separation emerged: waiting in coroutines, computing in workers.

Many years have passed, and in practice it has been proven that he
chose the right approach one that turned the once clumsy JavaScript
into a language capable of fast request handling.

Alongside the success of JavaScript, similar projects appeared in PHP.
There were many of them. One of the first was probably Workerman,
though I can hardly remember now.

Do you really think all these people were trying to make PHP
asynchronous for reasons other than practical needs?

Concurrent I/O for PHP is probably one of the most important features
that should have been implemented many years ago. Because PHP is a
server-side programming language, and a server-side language must be
able to handle I/O efficiently. This is far more important than
parallelism.
The concurrent I/O does not negate parallelism and can, and should, be
used together with it.

As for the list of tasks that concurrent I/O solves, it is quite large:
https://github.com/true-async/php-true-async-rfc/discussions/9

I have been programming in PHP for more than 20 years in commercial
development, and for about 15 of those years I have been missing good
async support and convenient parallelism in PHP. I tried Swoole and
AMPHP to meet those needs, but in the end I chose the only correct
path, one I am absolutely confident in. You cannot build asynchronous
applications in a language that does not support them. That is the
conclusion of all my attempts.

That is why I am here today, doing what I am doing.

As for parallelism in PHP, you can take a look at my research work on
the topic, where future capabilities of the language and possible
modifications are analyzed:
https://medium.com/@edmond.ht/multithreading-in-php-looking-to-the-future-4f42a48e47fe
Just to clarify, this text is not a product of imagination, but the
result of experiments with the PHP core, partially implemented.

----
Best regards, Ed

Reply via email to