Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:126570 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 qa.php.net (Postfix) with ESMTPS id 97F481A00BC for ; Tue, 4 Mar 2025 22:54:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1741128717; bh=vf+zpDUiDocc0+GTb65C7HrutuQ29ETiTVa5p9eBUEQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=HV836LCBKdZU4PHUgmH+V6uGGKPoHYFziQ51BE5U4Rbwtel5puFnwPNGsgmtUGxT9 /ElAsMa15aN5ZihVojmRbzjWbMZUERfImWMcDsi9qsrM6YD9B+M52nYJDGfvzT+v2Q eHy4S7XquPdvyYbuQMSNYyHZRppihQqUQYyUgnI/zKVnISb9m3av2FDt9YHQdEbLhy 5aLK4xW88lV8Nrno/+8XEmsLIuIfG4niXyze1ZUkAj5N4Ihyl57OZ0cx3lR+xK6WDm 8x90DfU6QQOD4F3jSpVBghylSYHIkSDoJcWUs1FAGGmDSSqRlN/pITSUrnM5b0xO3c 0T6KNcyvJ6HJg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 6EFFC180081 for ; Tue, 4 Mar 2025 22:51:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f180.google.com (mail-yb1-f180.google.com [209.85.219.180]) (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 ; Tue, 4 Mar 2025 22:51:56 +0000 (UTC) Received: by mail-yb1-f180.google.com with SMTP id 3f1490d57ef6-e53ef7462b6so5166234276.3 for ; Tue, 04 Mar 2025 14:54:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741128871; x=1741733671; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=1dkosD81eU6SYycuQjA33qqWBlvH99QX9H/2mlwlpeg=; b=f+eprCkKc8Tikm3ALC87pDfqU91wflO45HJ2OSb1dHUdJwTEi9Hf4bJKHMXk3KPcRm CKbYb28m8+b1t6JemrVmxZJ2mpjgd87RXp8tw8tnHWB9YQKV3aEvZ92W998Aaxybfz1J xYeHRbGQ2Nmq+0tZJWKT/vBd2zmgmhxu9K5PUltAQhpNv45YjQpnd4h/eYZVVOi4c+rk Hq9wUkJNSFarZP62ORLbW4Sj8TkEkCrVwi04Ld/qj0HS9E1c4y7e4sf0uyqvwFTVJTdz NoZ10ypImQcjOp8/EilVf6Tth/ANx3Hgjq5xG54Bzex9J1fq12/gWLfpq513/AOrPz+4 FySQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741128871; x=1741733671; h=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=1dkosD81eU6SYycuQjA33qqWBlvH99QX9H/2mlwlpeg=; b=arK4Lle937IQr2J8hstSoFEdgIgzj+55B3cvf5veT6Xe3xcaU+eeruvfRpX99MFPYm Hj7ivjfNSCW5+XBfNlV0BtdampuME6ddQ0kDATGE+jGj9z0tYzx9EGIMjEzOsNJC9F4v zV+0EUwdmPlbkMZ87/Xg1rnVoS6dHm3KALRslTEKJ7lg2WauNuzWZVRjnNxJZYFYlfBV wqUQ/c1U/D1H7RTEw/E4gms5/CJ6Wr7FDDm+ls2E92YyAtHygOxdRn2jPLoPD5nvGsTG 8LvKOwCQhi1OQBYtdBa80VbjKMDALhLDDcyaHpJLrq95+3k7YbEGQPH0c/acgkdNViNQ mcKA== X-Gm-Message-State: AOJu0YwA5Bp+8Orag0j/ZLlwoMQK68eWI05DwBWZmcO8RP95gKck85PD A7+gK2wwWQH+iK9GupxeYcIieQATvsaSQ1CbXCyXwwTeQnHmLhVHrwb/KFq8cAa5v/DLbCoduAW YkfA3kLJ1/OsUBweLzprLy1XaDhmp6w== X-Gm-Gg: ASbGncvIQL/zYWaO178PuN2YDdlvzPx7SKIDEb06QsimP0HFOVc7W0TzwnSfq6YhpCb A4/XHGzepjsvbnafmXQBvbcRsKqwKwWtundLUVBSLjs6cJrU1dzKPg6BiooV2l6ejYIUPaqDaMW sDp1ovRwYK02jbcdh2+Wdi21o8toYa X-Google-Smtp-Source: AGHT+IGv3fp3ekFXFaQg4JXlR71eWlRPgWUCoGnKRJnSKp4Z1wM8gPgBwGHtfmyAh6vskBUpU4Yn3E+rtBgjMQZ+S1k= X-Received: by 2002:a05:6902:3401:b0:e60:8c90:d8ae with SMTP id 3f1490d57ef6-e611e305029mr1352192276.37.1741128871511; Tue, 04 Mar 2025 14:54:31 -0800 (PST) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <9964db8c-0ffe-43d5-8246-47fc76b07180@app.fastmail.com> In-Reply-To: <9964db8c-0ffe-43d5-8246-47fc76b07180@app.fastmail.com> Date: Wed, 5 Mar 2025 00:54:19 +0200 X-Gm-Features: AQ5f1JrpmpmFx82s0HBIdC4JCN4fEywOkfdD4u1zcCZKQVN_ZOviwhw3x8IAOII Message-ID: Subject: Re: [PHP-DEV] PHP True Async RFC To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="000000000000e51330062f8c274d" From: zsidelnik@gmail.com (Eugene Sidelnyk) --000000000000e51330062f8c274d Content-Type: text/plain; charset="UTF-8" Hi there, I would also like to highlight some interesting ideas that I find being useful to consider. Recently Bend programming language has been released, and it incorporates a completely different view on the conception of "code", in the definition of "what it is" and "how it should be interpreted". While we interpret it as a sequence of instructions, the proper way of seeing it is the graph of instructions. On every step we reduce that graph, by running the code of the nodes current node depends on. Therefore, basically everything could paralleled w/o the need to have fancy management of threads and other low-level things. For example, having this code: $foo = foo(); $bar = bar(); $baz = $foo + $bar; If it was run in Bend, it would be interpreted so that foo() and bar() functions are executed in parallel, and $baz = $foo + $bar is executed afterwards, since this computation depends on the other two. The key, most excellently beautiful feature here is that all async management is under the hood, exposing nothing for the developers to be bothered with. That being said, I also want to mention that Bend has a primitive for concurrent loops. Actually, they used another solution, different from loops, since loops are sequential by their essense (iterative one by one). They introduced a concurrent alternative for loops with "bend" keyword, allowing data structures to be traversed in parallel. I think this is actually "the right way" of doing parallel processing in general and async programming in particular, and this is greatly to be considered for having at least some principles applied in PHP. What I think it could be. async function baz(): int { $foo = foo(); $bar = bar(); return $foo + $bar; } // value is returned just like from any other ordinary function $val = baz(); Function above could run foo() in one fiber, and bar() in another, both of them being awaited at the return statement (at the first statement where the value is actually used / referenced, if we put it more generally) so that actual values could be taken. In other words, async function is not promise-based as in other languages that suffer from red blue function problem, but rather it is function with coroutine flow of execution, so that foo() is executed as the first coroutine, and when it blocks, then bar() is executed until it also blocks. Then, at plus operator being evaluated, $foo is awaited, and $bar is awaited, since they are necessary parts for + operation to complete. Best regards --000000000000e51330062f8c274d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi there,

I would also like to highlight some interesting ideas that I find being= useful to consider.

Recently = Bend programming language has been released, and it incorporates a complete= ly different view on the conception of "code", in the definition = of "what it is" and "how it should be interpreted".

While we interpret it as a = sequence of instructions, the proper way of seeing it is the graph of instr= uctions. On every step we reduce that graph, by running the code of the nod= es current node depends on.=C2=A0

Therefore, basically everything could paralleled w/o the need to = have fancy management of threads and other low-level things.

For example, having this code:
<= div dir=3D"auto">
$foo =3D foo();
$bar =3D bar();
$baz =3D $foo + $bar;

If it was run in Bend, it wo= uld be interpreted so that foo() and bar() functions are executed in parall= el, and $baz =3D $foo + $bar=C2=A0is executed afterwards, since this comput= ation depends on the other two.

The key, most excellently beautiful feature=C2=A0
here is that all async management is under the hood, exposing not= hing for the developers to be bothered with.

That being said, I also want to mention that Bend has = a primitive for concurrent loops. Actually, they used another solution, dif= ferent from loops, since loops are sequential by their essense (iterative o= ne by one). They introduced a concurrent alternative for loops with "b= end" keyword, allowing data structures to be traversed in parallel.

I think this is actually &= quot;the right way" of doing parallel processing in general and async = programming in particular, and this is greatly to be considered for having = at least some principles applied in PHP.

<= div dir=3D"auto">What I think it could be.

async function baz(): int {
=C2= =A0 $foo =3D foo();
=C2=A0 $bar =3D bar();

=C2=A0 return $foo + $bar;
<= div dir=3D"auto">}

// va= lue is returned just like from any other ordinary function
$val =3D baz();=C2=A0

Function above could run foo() in one fiber, and bar() in another, bot= h of them being awaited at the return statement (at the first statement whe= re the value is actually used / referenced, if we put it more generally) so= that actual values could be taken.

In other words, async function is not promise-based as in other= languages that suffer from red blue function problem, but rather it is fun= ction with coroutine flow of execution, so that foo() is executed as the fi= rst coroutine, and when it blocks, then bar() is executed until it also blo= cks. Then, at plus operator being evaluated, $foo is awaited, and $bar is a= waited, since they are necessary parts for + operation to complete.


Bes= t regards
--000000000000e51330062f8c274d--