Hello Dennis. > With all that in place, userland can now create their own Scheduler/Rector.
I once wrote about why such solutions are unsuccessful — and clearly bad from PHP’s point of view. But since I don’t remember where that text was, I’ll try to express it again. Programming languages have levels of abstraction, which researchers have been trying to quantify mathematically since the 1970s. PHP is a high-level programming language with a relatively high degree of abstraction, thanks to its memory management, built-in runtime, and abstraction over the operating system. Suppose someone created an RFC proposing to add assembly inserts into PHP. Would you vote in favor of this RFC? If not, why? Most software — almost all of it — from operating systems to browsers, is built on the principles of multilayered architecture, where abstractions are separated into distinct layers. This is done to reduce and control interdependencies, which directly affects what are probably the three most important parameters in programming: the cost of code, the cost of debugging, and the cost of refactoring. For this architecture to work, developers try to follow the **Strict Layering** rule (known by other terms in different contexts), which states that code from a higher-level layer must not interact with a lower-level layer while skipping the intermediate one. Although this rule is almost always violated, adhering to it is justified in most cases. Assembly inserts in PHP violate the **Strict Layering** rule and give the programmer the ability to completely break the language’s operation, since they belong to the lowest layer. A Fiber in PHP is a context that stores a pointer to the C stack, CPU registers, and part of the VM state, combined with a generator. Fibers cannot be used as coroutines because this approach is inefficient in terms of performance and memory. The reason is that a Fiber is an extremely low-level primitive — only slightly higher than assembly. Let’s recall what a full-fledged abstraction of asynchrony looks like in any proper programming language: https://editor.plantuml.com/uml/TLBDRjGm4BxFKunw0QJTvSu1LQfQgH9L4HLmTftPpQYE7SrCkXigtXqx8MxOYfF7zZVVZyUNQaviw0Be4yVUYUimS2GRUy97-iKa0COM2B-HyvPasmW_KyIh96cm3CMxr5004FBcuY4ZBwvFvFDTAgXeT39yVyEF91ykq6azUm74LLCbd41r1x__eNxmBJL389bGTOSlPxZPxOpwMvyBNkSOXbzIwWjgAWh9Exm9wOXfZxJ4WDUms-tdolS9tT6nuUt7UwH21ijDHbLl1HUJyNv48TUCw6kqIlkcOMGA3QQ8aKusom1a5aBXGsl5NOL3hJ9rD4b1NpKmy9xyw0FjuDPG1-qfDYk05fKvXuiD2kdGaOArrE6nfLZJ2lL9JASGfKztGBcXc3gpjamOtlw3DeKi_kCErPpH1lBYdpQJyjNNxoXqO3KItQtUPXu3AHxPMex8zb_bnMmTH9SYvrLnpu6m8VN2VJdOW76NXMPjvKDqGV6P7Tu_xE1d2UxYF5LCtWy5oJOFacdryrPUBdCrTE4F Therefore, Fibers violate the **Strict Layering** principle, and PHP has no way to prevent this — unlike Rust, for example, where you can hide parts of the implementation within a crate (package). Even in C++, there is no such violation — the programmer works with the coroutine abstraction. It is also important to understand the difference between PHP and C++/Rust: PHP is a single-runtime language. When you have multiple runtime libraries, for example asynchronous ones, a segmentation problem arises: you cannot simply use code written for runtime A in runtime B, because the runtimes are incompatible! What made PHP popular? What made Go popular? That’s right — the built-in runtime! Just write code. Just a week or two ago, I read an article from the Python community discussing the problems caused by the segmentation of asynchronous libraries. And let me remind you, that Python has had built-in language-level support for asynchrony since 2015. So... I’m convinced that PHP should remain a high-level language with a built-in runtime (at least as long as it’s interpreted). Attempts to create a “backdoor” in the language to let libraries implement what should be written in C bring no benefit to PHP users. After all, to use asynchrony, it’s not enough to just add `spawn` or coroutines. Libraries and frameworks must also be adapted, and all of that takes time. Go added more abstractions to the language to make writing business logic easier. Python will soon implement JIT. People will choose the tool that “just works” with minimal effort and they won’t care what it’s called. --- Best regards, Ed
