Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129038 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 272CD1A00BC for ; Sat, 1 Nov 2025 07:33:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1761982384; bh=UTV0KqP7RHS5+Wh0zHSgEU7gBkjDEZuWRtUGy1/Nlaw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=cukKUv+8J3QijrUbtgBCdFEamkYo4p2uWERy+XPcQyDLqdBCW1KPrOVrT7qU82ImD Byc3sqEwOxTUEO47HotoKQr0pmjm6kh6kH6fIiaOtoHkjCwLEHwzh99wzAP88NuyPD bYCkDc9ekfg+fBFi/ib0XiohOSiGc3zGm46Axaezqj8vJvA8tNw9pdIZWWcktn4WT5 r44kubDz2J1QJ7Qp9+7JpMyr5dDZaZzWUwqi+Tu5+cWR+FPonFQy+UQ2KVDClzpcEP gyLze5seaC5+dfdFUY7lGLa7coDCUZVqYxRlUxTejXYTgSrqX1JLHMVhKOEPlADCXh 9vLmTNyIF4OAw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id C21B6180039 for ; Sat, 1 Nov 2025 07:33:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-vs1-f46.google.com (mail-vs1-f46.google.com [209.85.217.46]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sat, 1 Nov 2025 07:33:03 +0000 (UTC) Received: by mail-vs1-f46.google.com with SMTP id ada2fe7eead31-580144a31b0so2121719137.0 for ; Sat, 01 Nov 2025 00:32:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761982378; x=1762587178; darn=lists.php.net; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=+zOh/YhZ3V8Ry7Ktly7PUCP4+WpUYKdp5bvWnmFy+fI=; b=JcDEIUtoCoI1MPrjibIc9OWcZCJkJDEDKLWlWkTPo+m07QzhEJL3pq1pdo3GuEV77p JWP+8V6miK0nd57rBR+BMxe3jVUCN6jdi0KmELVx8mBU3upOldsXoYqKcubt0XWaFjti nzQg5LqXPSDYfTC4mm6uP0XXSOvKrwe59Flsk7KhZbgPEvphQ/G6bMoZ520WLwOuVo3t mvfOUskM5fpC7nM+shpLwHheL7cVK2//vWWsEGQWOFUf9auZTbKfQ2olMLid8c/bjrHq tTjThKOXJcDdwkbe3MuK/itgnda25kBCZ8bSMgcaAyc8QkUhmCht0O2mNhkN5Hoy8mNu +B2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761982378; x=1762587178; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+zOh/YhZ3V8Ry7Ktly7PUCP4+WpUYKdp5bvWnmFy+fI=; b=lRZBCvbzgpOoa2ef1j18Aw5BNcTcw54O9tkISTvcGhQlJQnoAGU73emcMuLibTLlGP Ja4q/8Yhohi+8J16+AyoqXhsirFsMujP9Q3yojzda6tC48WmmVRNHoOSEowIwdkC+mih eP/oFNSlrl1KG0ojRXJ1kDokULGL5ZFW84Wqoz48DOI3ZGfPENV5sP449NNWQe21DDeY zE57TgdPuCj0KmaHTSfX38Y9jYfC+cYWSxBo5XGRdbdtHN/Po0fbudNdPY3Bh7JazZRc u0Co4BYb01vqcqal/c4CK7dNi5hFPlMvat6CgVmCx9/9dTHLFIg54AuuBBSgdgPyCPv8 jKkg== X-Gm-Message-State: AOJu0YyBTYdWsQgpMB42OjQSkpozym/+t1mjLYFn8n2LaW/HOQeOaCsp aCnObTvDQzH6DPr82oKfCY2yJytc6EpTHdsfGh/VkAWU750lgz9yYnzUEg4MEAgSK0I7zq46l+l bK9W5VD16UneI2wbjq07R36/p0aiJjy7K94KH88c= X-Gm-Gg: ASbGncsLaLRTOtjACUbOQhV2XhcRdsYexHgfe1k3Ym3I4z0YWWul1TVhKcSscOSmBhp sIcJJtWQqSoOUmVe+WMPBjmvDBDIAeEQu6CcpThgSg8omnGX6Dpqs1LyOYnM7unf9EwmpAdIjxX rMYQK5wCC//OZYhGhwNLVXC7RUcUaclysUgL3Vi7gh/k1mAxc2F37UaKNVPmNmGsj0BW1LOTP1D gIl2VeDlUneGlznhZlnchVQUezj+NzsPObgzGji7WtIXNkqCNUL9OmQiwtnnrGczMhKyTjRcLK+ 7Wfq6QOPkS/RtMm6 X-Google-Smtp-Source: AGHT+IHaay2sBbzaMgQ6HgO8K6BodzjjXa6PvOUeUlEX4+AGvYbp0tOFs4T0lexDwDRaY5cxafE4uGMfiw3D4jN4y5Y= X-Received: by 2002:a05:6102:620d:10b0:5db:b86c:2d7c with SMTP id ada2fe7eead31-5dbb86c2e0emr1131796137.15.1761982377653; Sat, 01 Nov 2025 00:32:57 -0700 (PDT) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: <2441aa9c-41c8-4ce1-b9c0-67136e5f97da@dennis.birkholz.biz> In-Reply-To: <2441aa9c-41c8-4ce1-b9c0-67136e5f97da@dennis.birkholz.biz> Date: Sat, 1 Nov 2025 09:32:46 +0200 X-Gm-Features: AWmQ_bnratIONhJOWqAwZl481A-chD2PM07UvVIMyayQ1CuEjbnMNRrTXXc90Fc Message-ID: Subject: Re: [PHP-DEV] PHP True Async RFC Stage 5 To: Dennis Birkholz Cc: internals@lists.php.net Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: edmond.ht@gmail.com (Edmond Dantes) Hello Dennis. > With all that in place, userland can now create their own Scheduler/Recto= r. I once wrote about why such solutions are unsuccessful =E2=80=94 and clearl= y bad from PHP=E2=80=99s point of view. But since I don=E2=80=99t remember where that text was, I=E2=80=99ll 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 =E2=80=94 almost all of it =E2=80=94 from operating systems t= o 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=E2=80=99s 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 =E2=80=94 on= ly slightly higher than assembly. Let=E2=80=99s recall what a full-fledged abstraction of asynchrony looks li= ke in any proper programming language: https://editor.plantuml.com/uml/TLBDRjGm4BxFKunw0QJTvSu1LQfQgH9L4HLmTftPpQY= E7SrCkXigtXqx8MxOYfF7zZVVZyUNQaviw0Be4yVUYUimS2GRUy97-iKa0COM2B-HyvPasmW_Ky= Ih96cm3CMxr5004FBcuY4ZBwvFvFDTAgXeT39yVyEF91ykq6azUm74LLCbd41r1x__eNxmBJL38= 9bGTOSlPxZPxOpwMvyBNkSOXbzIwWjgAWh9Exm9wOXfZxJ4WDUms-tdolS9tT6nuUt7UwH21ijD= HbLl1HUJyNv48TUCw6kqIlkcOMGA3QQ8aKusom1a5aBXGsl5NOL3hJ9rD4b1NpKmy9xyw0FjuDP= G1-qfDYk05fKvXuiD2kdGaOArrE6nfLZJ2lL9JASGfKztGBcXc3gpjamOtlw3DeKi_kCErPpH1l= BYdpQJyjNNxoXqO3KItQtUPXu3AHxPMex8zb_bnMmTH9SYvrLnpu6m8VN2VJdOW76NXMPjvKDqG= V6P7Tu_xE1d2UxYF5LCtWy5oJOFacdryrPUBdCrTE4F Therefore, Fibers violate the **Strict Layering** principle, and PHP has no way to prevent this =E2=80=94 unlike Rust, for example, where you ca= n hide parts of the implementation within a crate (package). Even in C++, there is no such violation =E2=80=94 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=E2=80=99s right =E2=80=94 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=E2=80=99m convinced that PHP should remain a high-level language with a built-in runtime (at least as long as it=E2=80=99s interpreted). Attempts to create a =E2=80=9Cbackdoor=E2=80=9D in the language to let libr= aries implement what should be written in C bring no benefit to PHP users. After all, to use asynchrony, it=E2=80=99s not enough to just add `spawn` o= r 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 =E2=80=9Cjust works=E2=80=9D with minimal = effort and they won=E2=80=99t care what it=E2=80=99s called. --- Best regards, Ed