Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125499 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 315A31ADAFE for ; Wed, 11 Sep 2024 02:57:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1726023572; bh=poOsYp5OW5LmvaswA7LFTaWkj5n58QSRfit847THVjs=; h=From:Subject:Date:Cc:To:From; b=k3a24dX0ZTjE+qEHD6PWDiCXzHCPd2l6von9gmFrgSGX3DWaRjD4kTTXVRyEWU5ml g5ilCVa+80KetuvxglI8nReUtl9ZcasihGjVj0tWKhJNuzgQZNnV7cRztUd8rdUb/3 +X4IeVKZg935ZQqTbncjWJovtfK6pY6pkR2wR3OazP3i98KRVKYLu3R4K9b9pw4ziF M37yF5qxQ0nDJO55zsIVI/r4hQAq1bl/zW2SF+0XVv+tuabEi9sEfo7OnS8vypU7by njZOJOD06umSqHk5MwjE8QooGYH2fWURhT6pKI8OtsMbuuQo3/HqSomGuYOkgOes6w NlmjqnI2GpUBA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AB53A1801DE for ; Wed, 11 Sep 2024 02:59:28 +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=0.8 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DMARC_MISSING,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com [209.85.219.171]) (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 ; Wed, 11 Sep 2024 02:59:26 +0000 (UTC) Received: by mail-yb1-f171.google.com with SMTP id 3f1490d57ef6-e1a7d43a226so6795654276.3 for ; Tue, 10 Sep 2024 19:57:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20230601.gappssmtp.com; s=20230601; t=1726023445; x=1726628245; darn=lists.php.net; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:from:to:cc:subject:date:message-id :reply-to; bh=o8ihTiwjz7ECKKTEO2QlGi+9FVl7Vk4HuV4GQItmzms=; b=1Zz1kkQwyN5Vy2dMcHg2VAz4ytwpCOU6bECIXrFYBsMKWNsCE6bk61ZWZwTwLxLAdf cv1mwtSkdknfGxPHOoKNrUVQmHsTbpRM+EXTOIPe0h5AW834ZA/P186VsYlR1D1C3Lqp egwQZkPJWgP00iS7dkWdCmxsCaDkoZHmkQ79JIYrBABXe/9w845ygLufTvcr/DiMN/2h 98Sc0J1IOvP3HYRUGnfj9WXVPQcGgDsE50UJqw/gcyWKU9LiM9my/qkGTgpvQ2zTlmu+ oeg+CZjSVrGxbhsNfxMqBbj68F7WUN8NAEIRtTEQuDBBGi8WvsJBI07VgGBPTJGQTbPT nUzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726023445; x=1726628245; h=to:cc:date:message-id:subject:mime-version :content-transfer-encoding:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=o8ihTiwjz7ECKKTEO2QlGi+9FVl7Vk4HuV4GQItmzms=; b=WTs38sfB1zaFuxOYkwoMe3kdn/BvmD4dZIw7ePsIsEVWyVIiu9cg8YjM9w+qxQf9ax nFFDozWn/XoaWOXo3MNcqm85nhYY1viyUKPcBSVDCfW74IHOXY6uwRnDu0ue/tO4t/AZ v342j5EwACU2+gNouI2dmRyo2bIJnKigCv5yepLP5gGXF1PNw5tMERBCQAp01S4w39rk r+0E1wlE6iolq3dGguZS1BTXCyUx4pfARWAUzRG0VspJviJeEmbcrxIY5PlyT1POXVVl uxwtDcQaPijHhAn6qzKJAj+BPkfZ77pRwYq+rGkfYM/QPu/gaIEuKrbGuKaH+QpFBGyX 1+JA== X-Gm-Message-State: AOJu0YxY00m75zEcCm1X84R06QNdVRcWPlmqD9vZUW4mgHbNZtS0MtSM C9vPs4aqCgyYpquZXgDlQb0/PEG3JQHKZnNVXorbzvUoZk7SRWKKcRbMxKn6xS7X2jbhvOK/1y7 DDuE= X-Google-Smtp-Source: AGHT+IHHCooAm4J5xLyHf8Ca1tVHGMSdq5CbrIWsg1pZZsemMusDxa+ceC7/5h5k3UFXa8lghluzUQ== X-Received: by 2002:a05:6902:15c8:b0:e0b:f6aa:8097 with SMTP id 3f1490d57ef6-e1d346afd31mr18267223276.0.1726023444487; Tue, 10 Sep 2024 19:57:24 -0700 (PDT) Received: from smtpclient.apple (c-98-252-216-111.hsd1.ga.comcast.net. [98.252.216.111]) by smtp.gmail.com with ESMTPSA id 3f1490d57ef6-e1d7bb9ba7asm537806276.47.2024.09.10.19.57.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Sep 2024 19:57:23 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.10\)) Subject: [PHP-DEV] Zephir, and other tangents Message-ID: Date: Tue, 10 Sep 2024 22:57:23 -0400 Cc: PHP internals To: "Rowan Tommins [IMSoP]" X-Mailer: Apple Mail (2.3696.120.41.1.10) From: mike@newclarity.net (Mike Schinkel) Hi Rowan, This message is in reply to https://externals.io/message/125455#125496 = from the thread "bikeshed: Typed Aliases" > On Sep 10, 2024, at 5:35 PM, Rowan Tommins [IMSoP] = wrote: > On 10 September 2024 19:32:19 BST, Mike Schinkel = wrote: >> BTW, why has nobody ever mentioned Zephir on this list (that I am = aware of?) >=20 > Zephir is an interesting idea that has never quite fulfilled its aims. = The Phalcon developers hoped that creating a more PHP-like language = would allow more people to work on extensions such as their framework, = but it doesn't seem to have worked out that way.=20 >=20 > The worse problem was that Zephir itself had very few contributors. A = few years ago, the project came close to shutting down as there was = nobody left to maintain it; Phalcon was to be rewritten in PHP. = Since then, = somebody has stepped up, but Phalcon work is still focussed on the PHP = rewrite, with the intention of a smaller, optional, extension providing = performance-critical components. = Thank you for the details about Zephir, as I was not fully aware of its = history. =20 On the surface it looks like a really promising project, it is a shame = that more people are not interested in seeing it be successful so that = it could be maintained and improved. BTW, my rhetorical comment asking why nobody mentions it on the list was = really an indirect reference to the "Using and Mentioning Third-party = Packages" thread[1] I have wanted to comment on but have not had the = time to read the full thread and craft an argument that I hope would be = compelling to many people. > Meanwhile, PHP 7 and 8 have massively increased both the performance = and the capability of code written in PHP, and even FFI to bridge to = existing native binaries (although I gather there's a lot that could be = improved to make that more useful). > > ...except to say that I think we should be aiming to reduce the = difference between what can be done in extensions and what in PHP code, = rather than planning any new such differences. True, but let us split this into two discussions. One discussion you = made here which is "make PHP better rather than make ways to extend PHP = externally."=20 The 2nd is the discussion I was having which was more constrained, i.e. = "In the case of operator overloading that I argue we should not offer in = userland I was exploring the idea of adding internal features that allow = extensions to be developed to address those use-cases, and especially = for extensions that would be included in core, not necessarily for = optional extensions." =20 Before we address the broad question let us address the narrow one I was = focused on.=20 First, do you think we should add general operator overloading as in = C++, Python, C#, Swift, Ruby, Kotlin and Dart, or do you agree that = adding it would be opening Pandora's box? If you think we should add = operator overloading then we can agree to disagree. If you agree we should not add then do you agree that we could add = operator overloading for specific classes in core, such as if we added a = Money or Currency class? Ignore whether you think we should add a Money = or Currency class =E2=80=94 assume we should =E2=80=94 and just answer = if you think we should allow operator overloading for classes added to = core where we can standardize the operator's meanings across all uses of = PHP? If you've gotten this far and we are still in agreement then I was = looking for a way to make it easier to add operator overloading for = classes to be added to core. So your comment "to reduce the difference = between what can be done in extensions and what in PHP code, rather than = planning any new such differences" was really presenting my argument as = apples when I was instead discussing oranges. Though I can certainly = understand if that was not previously clear to you, hopefully it is now. (Alternately, for operator overloading, do you see any way in which we = could constrain userland operator overloads such that we would not end = up many different competing meanings of plus, minus, times, divide, = equals, not equals, etc. for similar types of classes? I certainly = cannot envision how we could constrain it in a useful way.) ----------- With that covered I'll respond to your more general argument which I = characterized as you advocating to "Make PHP better rather than make = ways to extend PHP externally."=20 Generally, I agree. Where it is possible =E2=80=94 and not harmful =E2=80=94= to do so, it would be better to make PHP better than to just find ways = to extend PHP in other ways. =20 But let us be realistic and honest with each other. PHP has many = strengths but it also has weaknesses that it will never be able to = address without changing the essential nature of PHP and without huge BC = breakage.=20 And for those things were PHP is not great =E2=80=94 or where we see = foot-guns so we explicitly do not want to add to userland =E2=80=94 it = would make sense to enable PHP to be extended through other means. And = *especially* in ways that do not require being in control of the server = PHP is running on given how ubiquitous managed hosting has become for = many who run PHP apps. I discussed with you privately several years ago how I thought = supporting WebAssembly[2][3] would be huge boon to PHP, and at the time = I seem to remember you barely knew about it and were thus dismissive. = IMO then and now, supporting WASM in PHP Core would make certain things = possible that would only otherwise be possible in extensions written in = C or I guess via the FFI in other languages, but make it possible = without having control of the server PHP is running on, and in any = language that supports WASM. What things is PHP not great at? Real-time code, not using lots of = memory when processing huge data structures, C-levels of performance, = and probably a few other things. =20 The thing is, if we allow people to extend PHP in other ways and PHP is = just as good as extending in those other ways, people will almost = universally default to using PHP. So I don't see danger in harming PHP = by enabling PHP to be extended in other languages for those things PHP = is not good at. > The overall trend is to have only what's absolutely necessary in an = extension. Not sure what you mean here. When I say "extension in core" I mean an = extension that ships with core. If that is a trend to move away from for = some reason then substitute "in core" for every place I wrote "an = extension in core." Effectively that point is red herring for the point = I was trying to make. > and there have even been suggestions that some built-in functions = would be better off implemented in PHP itself, if the right low-level = features were included. Now implementing PHP in PHP =E2=80=94 assuming I understand what you = mean =E2=80=94 is something I have been wanting and occasionally = mentioning for years.=20 Specifically I think it would make great sense to have some of the = standard library that ships in core to be written in PHP which would = open up the ability for more people to contribute to PHP core taking = some burden off the maintainers of core who program in C, and would mean = that every improvement in the C part of PHP would make all the PHP parts = of PHP better. Is that what you meant? =20 If yes, want to collaborate on an RFC? I know at least a few others who = would jump at the change to pursue this. -Mike [1] https://externals.io/message/125279 [2] https://en.wikipedia.org/wiki/WebAssembly [3] https://webassembly.org/=