Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125618 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 4825B1A00BD for ; Wed, 18 Sep 2024 11:08:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1726657846; bh=vX+DhMbY1AMqWmd37BpoD1sQX9P2j//Hg0MhFkrz1vM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=g00FIyQSP/XBEnLeE/oF2D+wSh25xPAgUCju4iKBAsbCN0/mzz2vdlXrzZ4M8JbuP LcRAnX4jDc1/GTjWacCoWp4t787xl30VpQOJHLO9YzU0igp117DHUPKnw8HgRBKxkP 8RdK8IcUkffND7rstIYQ8IasQmfiGRRfXyGyKfeoe4TkreMJDj7gsxdkHU1x7Wkx+X teZT0ICF1k1NkWsgKBa+DDJfUqQ10f56rImV5gT9C+/++OzpPOQ8c+UDKedFN0Uzn4 reRUTfHKe4lbQSTzYiXk+bGwfq3UYDMGAvVi/Mxrz8V4VG0CA55zGmvDI+EDoAwif3 qpD5iSQ49VBlg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 093F3180042 for ; Wed, 18 Sep 2024 11:10:46 +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.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mx1.dfw.automattic.com (mx1.dfw.automattic.com [192.0.84.151]) (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, 18 Sep 2024 11:10:45 +0000 (UTC) Received: from localhost (localhost.localdomain [127.0.0.1]) by mx1.dfw.automattic.com (Postfix) with ESMTP id 7DFD6340D84 for ; Wed, 18 Sep 2024 11:08:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=automattic.com; h=content-transfer-encoding:content-type:content-type:subject :subject:message-id:date:date:from:from:in-reply-to:references :mime-version:received:received:received:received:received; s= automattic1; t=1726657719; bh=vX+DhMbY1AMqWmd37BpoD1sQX9P2j//Hg0 MhFkrz1vM=; b=Bq7W0NXwqbO+GO90ayUXyHwb8EyOC3GlT+XkHy/4IGYX1NxDGX htf+Gn2i/7rXQ7y+Lg16ZkGhepz2/uDTp2aHw4K0YVBCCOkydS65hu/piQbpKnhP Q7gAZ9rZAPEJsvl1kv86u34ihyJnTm7I7kcYleYeESSOJ5ZBw3+CYBh/mCCboxIM xw5oHgjnFOk6rWw95xP0I/lK2UucP1onsPAigZuzRC8ovTm6b/LUFahrjdNoLQBj t2SQBjH2P0YiNtvRftkle2C2eGCxA0eaPt72PloJMDqhyX3n6zyZooBUF7dDuB48 9CZHBc4HiyPH8YPXsZAZagRQhChcJK6wrZDQ== X-Virus-Scanned: Debian amavisd-new at wordpress.com Received: from mx1.dfw.automattic.com ([127.0.0.1]) by localhost (mx1.dfw.automattic.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id M1RBYhvU9f1E for ; Wed, 18 Sep 2024 11:08:39 +0000 (UTC) Received: from smtp-gw2.dfw.automattic.com (smtp-gw2.dfw.automattic.com [192.0.95.72]) (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 mx1.dfw.automattic.com (Postfix) with ESMTPS id 1BEF8340E64 for ; Wed, 18 Sep 2024 11:08:39 +0000 (UTC) Authentication-Results: mail.automattic.com; dkim=pass (2048-bit key; unprotected) header.d=automattic.com header.i=@automattic.com header.b="Nl2L0OuC"; dkim=pass (2048-bit key; unprotected) header.d=automattic.com header.i=@automattic.com header.b="cSRJPPdh"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=automattic.com header.i=@automattic.com header.b="eLTe4YGl"; dkim-atps=neutral Received: from smtp-gw2.dfw.automattic.com (localhost.localdomain [127.0.0.1]) (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 smtp-gw2.dfw.automattic.com (Postfix) with ESMTPS id 0C77DA0A0C for ; Wed, 18 Sep 2024 11:08:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=automattic.com; s=automattic2; t=1726657719; bh=vX+DhMbY1AMqWmd37BpoD1sQX9P2j//Hg0MhFkrz1vM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Nl2L0OuCFc9dKWBGjqVNmWDt5nd6VNCabh0pAERIa2v2lwWvtay4Lodlk2vP33PwH vxR8QaqM4lLmjqX4WYEPL1EsBirnMaPmdAj8T8lUGN7i0YOj+FqcOwXYR4jOR3vhsa GgwFZGX6ncS8n5wU/PGeSk6BMNRq+bwOjFcXdZ4z7P0VrpSb2FkZAuNwqyxDC0T3Ad UHCCgYW7bK/0CwNPduJ+uimB+4q9yq/u3pL0dKft9H6yFtloMkt18b82gE8ts5DYYp 28coXzT8KuwnhW6rYguPQ9wOb7XuJrxWK/mjdInfKFOzC83K9ihLmuDVWqO1PKs14H jwxiXeW3JNo3A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=automattic.com; s=automattic1; t=1726657719; bh=vX+DhMbY1AMqWmd37BpoD1sQX9P2j//Hg0MhFkrz1vM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=cSRJPPdh5BH1PEvYjeBBmgfmObjkfiipgus7AE72CAzBmkVv08Gfe3Cod3FHG2P0c 4hAdsKSaecVBW1yQ/w7PzcZWOQULtK3teN3LKAShtWE2OrYRBe+Cy1gVH4k78t3qb1 N/KTJap0h1H56PyohJVIuXLNe7vwcvlmXr9hYhMKesvN6AKnHbGhLo/70MiPCBfObK MrOH+lGBM/sib7AA/0zrS1m6zRkc+E+CqtyH5uy4DmihD4O97w34Jfq2LUiaV/bO6b CkUCp5DQjmUEe5bO/nra+xaSKxxzhH0P60qn2obt8sD5EZjPQKUPQp6La+SV3DY8P/ Cy9R64mBwM9Tw== Received: from mail-vk1-f199.google.com (mail-vk1-f199.google.com [209.85.221.199]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-gw2.dfw.automattic.com (Postfix) with ESMTPS id F25FEA03C3 for ; Wed, 18 Sep 2024 11:08:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=automattic.com; s=automattic2; t=1726657718; bh=vX+DhMbY1AMqWmd37BpoD1sQX9P2j//Hg0MhFkrz1vM=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=eLTe4YGls16UY8oRh8Iry+WNLkiR1IbYrmVCUfambKqKWZPcpQCaHtp7zFDx7ChEY VKwm4izBbs+j0Bt2xyMUa1nTCXu/HRWVW7i0pM71yooNvNYpjwYC3Lbhsn7HvcdR5i oW2wVHQjSTvbjnhiWbsC5cBmYDuhQnWlWic/K+RvLkh+yvWQ+FUFk7KhtUGCKRUahR j4d4c4Q5hmuJJsHJhb7KaLvzi9MSD8yXS259Lisq+3w7SvNik7J84dVAcNV3Y1ZuMX mA5e0OflmsXO/7oO2uGhu1kzFmd/5gLJFdV2bcdy4m8C4veg/u3LLcXB9vgwUbVH6i XNLkUT+8bK5tg== Received: by mail-vk1-f199.google.com with SMTP id 71dfb90a1353d-5010f1ddd16so1185619e0c.0 for ; Wed, 18 Sep 2024 04:08:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726657718; x=1727262518; 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=vX+DhMbY1AMqWmd37BpoD1sQX9P2j//Hg0MhFkrz1vM=; b=w3raiyMIIBJZcd546alZ8yMq8lkPfTaILqvNhgJffcq4+xNufmmNvKzLjzst/BPOWp DA24Vpw8LpQNJMlviSLaeORgBT20ZAzREetkP2QxX/IfP2VGD9LB1OqvPOGU7vmOakf1 j6mbuAcwtgEocF6Ivq/ybBzbA2i+ml/o+lAPpGnW+Yz6qG6U2uj3HHE8pX3UYtHeicEm 8aPXbGlz/dIJaQE+GXjJr+tZOA1JbIGGhLOf8FbAz8cxiKvjDUEvTLN/5GF5u55udTdY Di+cBj/V7yz2UJSS3xTZrRWMQmfWMQlc+6Zjuzwd+1AypLXuiMZczppliCbB2U0Dinf5 uj+Q== X-Forwarded-Encrypted: i=1; AJvYcCX3Ym0Lh9n5fJK3aT4hUZY8HECx5W30kuaI+bdlLGqJcMOAy5zdep9fILUNedc9gzLfZpwaVRhsk9s=@lists.php.net X-Gm-Message-State: AOJu0YydVXmeuQ6p9B8o+JwEHlYelWtvpLeAjkJTzM1gN7YRpUPUsE6E KaBKm8XT36zhAlLfGYikS6S0olAPtW3Kz26KuzKHIit3hoRGoybS8G6xALhvSzBgtb2pPk9zo2p 16ZIkmMrIDTjL7egiEqw/Fxt4J9M5jnXKHgkXV1qC3RB5prmCqH3GGakRb77FsE+y8KajhUdkMs wL8q5i2dOHXvEauTFuQc1oICRjW8YrvA== X-Received: by 2002:a05:6122:16a7:b0:503:1bba:5988 with SMTP id 71dfb90a1353d-50344b4f403mr11677084e0c.1.1726657718001; Wed, 18 Sep 2024 04:08:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGrMuW3fN2lnLkFjW+ljMpyVHKG/VdvNAknozvy1y3aSv0R3pIfyHJ0BluQ+n0GNK6P7xvCApJsfx0fS6MT1Fg= X-Received: by 2002:a05:6122:16a7:b0:503:1bba:5988 with SMTP id 71dfb90a1353d-50344b4f403mr11677075e0c.1.1726657717581; Wed, 18 Sep 2024 04:08:37 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: <8D420123-4ECF-48FD-A9C3-F80C60457A37@newclarity.net> In-Reply-To: Date: Wed, 18 Sep 2024 13:08:26 +0200 Message-ID: Subject: Re: [PHP-DEV] Zephir, and other tangents To: Mike Schinkel Cc: Adam Zielinski , PHP internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: adam.zielinski@automattic.com (Adam Zielinski) On Tue, Sep 17, 2024 at 9:17=E2=80=AFPM Mike Schinkel = wrote: > > On Sep 17, 2024, at 8:57 AM, Adam Zielinski wrote: > > > To summarize, I think PHP would benefit from: > > > > 1. Adding WASM for simple low-level extensibility that could run on > > shared hosts for things that are just not possible in PHP as described = a > > few paragraphs prior, and where we could enhance functionality over tim= e, > > > > 2. Constantly improving PHP the language, which is what you are solely > > advocating for over extensibility, > Hi Mike, > > I=E2=80=99m Adam, I'm building WordPress Playground [1] =E2=80=93 it's Wo= rdPress running in the browser via a WebAssembly PHP build [2]. I'm excited= to see this discussion and wanted to offer my perspective. > > WebAssembly support in PHP core would be a huge security and productivity= improvement for the PHP and WordPress communities. > > > To summarize, I think PHP would benefit from: > > > > 1. Adding WASM for simple low-level extensibility that could run on > > shared hosts for things that are just not possible in PHP as described = a > > few paragraphs prior, and where we could enhance functionality over tim= e, > > Exactly this! With WASM, WordPress would get access to fast, safe, and ba= ttle-tested libraries. > > Today, we're recreating a lot of existing libraries just to be able to us= e them in PHP, e.g. parsers for HTML [3], XML [4], Zip [5], MySQL [6], or a= n HTTP client [7]. There are just no viable alternatives. Viable, as in wor= king on all webhosts, having stellar compliance with each format's specific= ation, supporting stream parsing, and having low footprint. For example, th= e curl PHP extensions is brilliant, but it's unavailable on many webhosts. > > With WebAssembly support, we could stop rewriting and start leaning on th= e popular C, Rust, etc. libraries instead. Who knows, maybe we could even p= olyfill the missing PHP extensions? > > > 2. Constantly improving PHP the language, which is what you are solely > > advocating for over extensibility, > > Just to add to that =E2=80=93 I think WASM support is important for PHP t= o stay relevant. There's an exponential advantage to building a library onc= e and reusing it across the language boundaries. A lot of companies is inve= sted in PHP and that won't change in a day. However, lacking access to the = WASM ecosystem, I can easily imagine the ecosystem slowly gravitating towar= ds JavaScript, Python, Go, Rust, and other WASM-enabled languages. > > Security-wise, WebAssembly is Sandboxed and would enable safe processing = of untrusted files. Vulnerabilities like Zip slip [8] wouldn't affect a san= dboxed filesystem. Perhaps we could even create a secure enclave for runnin= g composer packages and WordPress plugins without having to fully trust the= m. > > Another use-case is code reuse between JavaScript and PHP. I'm sceptical = this could work with reasonable speed and resource consumption, but let's a= ssume for a moment there is a ultra low overhead JavaScript runtime in WebA= ssembly. WordPress could have a consistent templating language. PHP backend= would render the website markup using the same templates and libraries as = the JavaScript frontend. Half the code would achieve the same task. > > Also, here's a few interesting "WASM in PHP" projects I found =E2=80=93 m= aybe they would be helpful: > - WebAssembly runtime built in PHP (!) https://github.com/jasperweyne/unw= asm > - WebAssembly runtime as a PHP language extension: https://github.com/vee= wee/ext-wasm > - WebAssembly runtime as a PHP language extension: https://github.com/ext= ism/php-sdk > > [1] https://github.com/WordPress/wordpress-playground/ > [2] https://github.com/WordPress/wordpress-playground/tree/trunk/packages= /php-wasm/compile > [3] https://developer.wordpress.org/reference/classes/wp_html_processor/ > [4] https://github.com/WordPress/wordpress-develop/pull/6713 > [5] https://github.com/WordPress/blueprints-library/blob/87afea1f9a244062= a14aeff3949aae054bf74b70/src/WordPress/Zip/ZipStreamReader.php > [6] https://github.com/WordPress/sqlite-database-integration/pull/157 > [7] https://github.com/WordPress/blueprints-library/blob/trunk/src/WordPr= ess/AsyncHttp/Client.php > [8] https://security.snyk.io/research/zip-slip-vulnerability > > > Thanks for this. It is super great information. > > Want to work on an RFC? > > -Mike I'm happy to work together on the RFC document. I won't be able to help with the implementation, though, which makes me nervous about this part of the "How To Create an RFC" page: > If you don't have the skills to fully implement your RFC and no-one volun= teers to code it, there is little chance your RFC will be successful. I know Steve Manuel from Dylibso [1] was highly interested in building WASM support for PHP core. He's the founder of Extism [2] and his team integrated a WASM runtime with PHP using FFI [3]. There's a conference recording where he does a live demo of running WASM modules as WordPress plugins [4]. He might be a better person to create an RFC with, as he also seemed keen to work on the implementation. I've reached out to him about this discussion. [1] https://dylibso.com/ [2] https://extism.org/ [3] https://github.com/extism/php-sdk [4] https://www.youtube.com/watch?v=3DChZpveTipPU&themeRefresh=3D1 (I think it was that one)