Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121296 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 92696 invoked from network); 13 Oct 2023 07:35:29 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 13 Oct 2023 07:35:29 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 7BD8C1804D0 for ; Fri, 13 Oct 2023 00:35:28 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 13 Oct 2023 00:35:28 -0700 (PDT) Received: by mail-ot1-f48.google.com with SMTP id 46e09a7af769-6c4f1f0774dso1205109a34.2 for ; Fri, 13 Oct 2023 00:35:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697182527; x=1697787327; 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=lltz8VzbnB5IqqD5dN0f+wO9G/mFZ5NS8vJ1e5Y4iI8=; b=LbI69eHGC7++N+XF18i7Bs9uHVYmFWCELuBTL57Brw36RANevO9Eb6x29R4xSX4KiQ c4D+fte/PTIxxEiliP3j2RxI4GkLrhjG85VZpXam7cjWEYWsylx/u1g2Q32s310wjM72 jnWDIMpFblPHQfJhp9I5FKAdNYA8TKM4UTUp795TwKUxPzimV8OrryIx5rgMdgKrIYLE 8nJ1MS28DR09FBu8xinbFBSiifjZongmbfkj0Po6KHmosiJe82WBSfaVdR+vsxKexCQV r3Z1GeFVDusYWcH0wwPcpslWYeJkod0UR2I5WReF6uQ39ycuFXqUa5LJqocg4PAdtshD Bfgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697182527; x=1697787327; 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=lltz8VzbnB5IqqD5dN0f+wO9G/mFZ5NS8vJ1e5Y4iI8=; b=gyg/jJ3jQIrnUxWwp2P/Y9vYaqYeX3occO13Y7Q3uTCN0D2M5XV6+e5dD7v8e7D8Gy FRhLK41RRRkcuyo+VtZSUgCmM+UZaALCL1AyFNOVSJ2v/Ieo26214m4redZFeqr+Pe6D 7C5BufqdvoQjN7eHoT5YP5mau88KTDpCuuhUD74vQuxb4nI4aVNRUN1RNfdGUlGIfnaX ucVpTSPsChSDGy8gvAfFZzbulXWoR7PYOYB3Q9HfNiMa9Y200OnpcmpUT7FluNxHhxma AGmUQMIzzwXCMcRVTTrJ4p+ehUmdt5d9bVI/goaZMgV+fEXl6smsHNy1enc8xEjwF5Hy fV/w== X-Gm-Message-State: AOJu0Yy50NkGOUAaQk1JLzGFXefyWtgjO0VEF+7kptUeqlQHyxnUTMBN P45VGyaJxDGEt+Ev6Y6dwQ2qGtT4ZH3QetvBfho= X-Google-Smtp-Source: AGHT+IGOYluMY6eSEG5pLFD5dEz3ocUV3kSleIhN/y1iTkOIl0q2tjn/pnPZOOqO5xl+0UUV9bXYj7YPZ1ZQKwPVHj4= X-Received: by 2002:a05:6830:1642:b0:6b9:c51c:f4d5 with SMTP id h2-20020a056830164200b006b9c51cf4d5mr28357040otr.10.1697182526968; Fri, 13 Oct 2023 00:35:26 -0700 (PDT) MIME-Version: 1.0 References: <0b72d5e0-94dc-8837-bfd4-d2e24ab9db05@online-presence.ca> In-Reply-To: Date: Fri, 13 Oct 2023 09:35:15 +0200 Message-ID: To: Deleu Cc: Lanre Waju , "internals@lists.php.net" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Why did fibers get added to php core over something more fleshed out like swoole? From: landers.robert@gmail.com (Robert Landers) On Fri, Oct 13, 2023 at 4:29=E2=80=AFAM Deleu wrote: > > On Thu, Oct 12, 2023 at 10:00=E2=80=AFPM Lanre Waju > wrote: > > > I find it puzzling that the PHP internals have chosen to delegate this > > specific functionality to userspace implementation. Fibers, in my view, > > seem somewhat limited without the addition of a third-party library or, > > at the very least, the necessity to implement an event loop in userland= . > > This raises questions, as it effectively obliges users to rely on > > third-party libraries to handle a fundamental feature rather than > > incorporating it into the core of PHP. > > > > Seems like your description here quite matches what the goal/aim for Fibe= rs > initially was; a low-level API to help userland libraries to build async > PHP code. > > > > Moreover, I'm curious about why PHPDBG doesn't implement the Language > > Server Protocol (LSP). Could it be due to its reliance on Xdebug? I cam= e > > across this discussion on https://externals.io/message/78456, which > > makes me wonder about the decision-making process within PHP internals. > > It sometimes seems as though certain choices may not align with the bes= t > > interests of the PHP community. I would appreciate it if you could > > provide insights into why this might not be the case. > > > > > > Lanre > > > > My personal, non-fact-checked guesswork about the current state is that P= HP > had a significant history of decisions that made future work on the > language harder. As time passed and the language had more and more featur= es > naturally the project becomes harder to maintain and navigate, which > affected how future decisions were made. The BC promise of PHP has always > been significantly high - some edge cases and significant BC breaks have > happened, but they're not the norm. Naturally the next step in this histo= ry > is to become more conservative. Userland libraries can have faster releas= e > cadence, requires PHP maintainers (bigger pool than C maintainers) and > breaking changes are a lesser problem to a certain extent. Discussions > around language evolution, editions, etc has happened as (among other > things) a possibility to make BC breaks less impactful to the world wide > web and lower the barrier in getting an RFC approved, but these discussio= ns > never led to a concrete implementation. > > As it currently stands, PHP is a solid language with stable and proven AP= Is > with Composer and Community packages covering the gap in consistency, > technology evolution and developer experience. I'm a big advocate for > having some language changes that makes common and fundamental use-cases > part of the language i.e. it's quite unfortunate that a 30 year old > language that powers the World Wide Web don't have a Request object, but > history has made PHP quite conservative and there hasn't been a significa= nt > change that invalidates the reason to be conservative yet. On top of that= , > some voters are extra conservative when the topic is added DX built-in to > the language, specially because DX can be subjective (see multi-line arro= w > function). > > Long story short, Fibers being something "incomplete" from a userland > perspective is a feature, not a bug. Look at it as the simplest, smallest > (while still being feature-complete) way to expose the ability to write > async code in PHP while Swoole is almost an ecosystem on its own. > > > -- > Marco Deleu To add to this as a dev who uses fibers quite a bit, they are a fantastic way to jump up a stack without using exceptions. Basically, if you are using exceptions for flow control, fibers are usually a good replacement. My only real issue with fibers is that when using nested fibers, you can't control which one you suspend to, you just suspend to whichever one is currently running. So, if you are writing a framework and call into a user's code, and they create a fiber and then call into your code that suspends ... there is a significant chance everything will explode. This makes creating frameworks that take advantage of fibers very hard because you have no way to protect your code (or your user's code) from exploding everything because they decided to use some async library that created a fiber. That's my only complaint though, because for writing applications, fibers are amazing when used well.