Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125583 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 99AB91A00BD for ; Tue, 17 Sep 2024 12:57:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1726577977; bh=8NXZaZu8/aZzAXzzYqs5WsCIljuwy2sMkyuXM0nlyd0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=YXWJttS0FlyHA7vp35GGwPqFCZlIn0LtHghpiYqGAYJGWKhz4/l5LT/47EKOGDZnJ 6h8vVwAKc9VBQ/D6wqkXvmLO5vng0iNbdZmVOizzxCvRMXbIPUJGf9/hRVeQ8GO6dT VY73hoFeQF4Q7Dui87cMS0tNE+AUiyUiBd6bnbApvqm9BxFU64QHvsRueQrYJa4cWq hb43eIJOTnKPa6Qg1TEbC5B9vTV/WeokIL00jDQ+7w3ewEiyoy5+jW4nWyMdmdXxjm x67IK1ncRHNkRRmUoPIGrp3f+hp+Yhp17l2W0hz2WG938aQh3vOvIuIGogD5QsSHFK wYj/43ijQYpoA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8C5D2180042 for ; Tue, 17 Sep 2024 12:59:36 +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,HTML_MESSAGE, 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 ; Tue, 17 Sep 2024 12:59:36 +0000 (UTC) Received: from localhost (localhost.localdomain [127.0.0.1]) by mx1.dfw.automattic.com (Postfix) with ESMTP id 246F1340E22 for ; Tue, 17 Sep 2024 12:57:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=automattic.com; h=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= 1726577850; bh=8NXZaZu8/aZzAXzzYqs5WsCIljuwy2sMkyuXM0nlyd0=; b=S JalEO6ctJHJRJzQ9uFXQSmVUlVy66g7Pjb0/seJNzWvbU7mpHPXZY+/ML3vWur3v r1IWTBZXM5lCPAzW1RhSc4udfiCWbO5sSwpHV3OfCUrMD2djdsd8f335j9IM0lW/ 4IHP3husVtEL7a5PQy38urn7bo7ks/0YNSgKaVyvYniYBfRKSnEfbrdD4/kxdUwA 3A24f7fdQ88A7H7VIh2Z8lNFbq4WYkONzC2+X9Y7DE/69T3pleNo8NmpcQNyXam9 y89x/I5rCYSuMIhnnWZ2eS7m4Tu6xpqpVjfFYk3784CxcCPuAoOFnoZF+o5SuS2c whyuZa/DzpuRONaDNs3VA== 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 mmJxIFFZWXDZ for ; Tue, 17 Sep 2024 12:57:30 +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 AD33C340D86 for ; Tue, 17 Sep 2024 12:57:30 +0000 (UTC) Authentication-Results: mail.automattic.com; dkim=pass (2048-bit key; unprotected) header.d=automattic.com header.i=@automattic.com header.b="XV+OMdTj"; dkim=pass (2048-bit key; unprotected) header.d=automattic.com header.i=@automattic.com header.b="X2NmYJUg"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=automattic.com header.i=@automattic.com header.b="HuI/Dazh"; 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 9DA6EA03AD for ; Tue, 17 Sep 2024 12:57:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=automattic.com; s=automattic2; t=1726577850; bh=8NXZaZu8/aZzAXzzYqs5WsCIljuwy2sMkyuXM0nlyd0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=XV+OMdTjcEQosSrwjeczPh+wROmeiUslmFRJTXBlaPeu87NBd8FF6pIVZV4qqfbJS MhMBxGDHFhIe/+9M3ltW8qnuLhbmzCioeF8yeTA7BPEUjLnAa7gnso40Fyz+gsXskH +2rblXcmq1N7vPf4f+jv81aNsY3q1wn5F1GfdFiT2oNRppAUbaF/cLDI0QvP7qQiJn qkYE2EkOO+elhKVcog3LApAoFT+9FfL/5oM3CT8An7CZypdWqa8hK+4SGZvbFsQBiT gO/PUFNQZB92A1vaxmkj8rPGCut+0BdAodRuMNkLw1EZwxLLBlNxLaTD5tgi6gILGI R7cFXMD3DJTNg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=automattic.com; s=automattic1; t=1726577850; bh=8NXZaZu8/aZzAXzzYqs5WsCIljuwy2sMkyuXM0nlyd0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=X2NmYJUg/VxhlvINbi5MCdUXq+p2dNAkCUV9iLYUPspVXTkyC4HVlMZznigaPtWJj 5AYG9ftxj104CZcuK1N9ctg3/7cUpQZY5qM0QCHjFJEBi5V21Lx3jNEcyROHgd8MFZ P6aKLoWLoYWn845Mv3fzjTOUnBO/FjXnxUpHzz/u0aOnLvikRzBDVM4QIhNBK0imTl HTOVcM7X4M7mKGTnMwNsn0jQ/LvJs/tnaW01UD2zf3qlVKYjhvKI9R4pTtv4ICm1jl uj3LWA/1wt0S3fdnos4B+1f9Pv6UeZisNgKQeHNYeEsh53SYX6uf5xCGowscUtSvit O97R6Uf+dcf6g== 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 856ADA0367 for ; Tue, 17 Sep 2024 12:57:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=automattic.com; s=automattic2; t=1726577850; bh=8NXZaZu8/aZzAXzzYqs5WsCIljuwy2sMkyuXM0nlyd0=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=HuI/DazhDynhndNnmvkY1Y8gVcwKgqPqVOehqLjjfaxEkRRvDC0ChlrJmsGcRph9F hHj/soIR4sL+QS5uyZF+YcZ7HsSPvi97B2YTeiWny+y2qzWeM8PLlHmwnuRbN8qL1I 3PGTPe2Wu6aXOJLzpZuTzGm0zpDKGkxgBKSMxpk7Q0yide9hPF1Cmk+pFydZ7r5Yas Mt6/jr4H4MPI5DuHnW7hc4gv5YKzvMiAglllaZJtZD9NK3JBCmSa3zulkpLqrizyj9 I5pMCgymmWAHXLUAni1SV+M9c6Nfq/uR9qnh/WkJeYZQsgK7ih6Jqf0h9u9YaePbEw DFASBZTIv2fGw== Received: by mail-vk1-f199.google.com with SMTP id 71dfb90a1353d-5010aa74180so1154716e0c.0 for ; Tue, 17 Sep 2024 05:57:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726577850; x=1727182650; 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=8NXZaZu8/aZzAXzzYqs5WsCIljuwy2sMkyuXM0nlyd0=; b=hD+tfyuseVXLNH53tfffUqijEwtO+uUC9F1f/Bc3frIVTdmVK5bpEJmjsG24n6GATN c9k8e69v+jQKLglFt0Z4ey5ZweKqoyc71V2HAlLsr71xK/L1bbq7Wv7goNVeLYdbjcfr E/NTFMjkqSAdkirL/Kle2GP6u5DP1Qb0BHC2wdNvmvZ3W1iqVH1lnTq7uyIrQ7h7yF3T LAz9AN7XQ8+BToDmjFoAD5H5RPO/3lM5Bjge4ynqOk8/da6JRutPyBG0PUT0B5me7A5B m0oY9ep6TxRYrK5U4Iv3XeiNIQuYASEO4U/0ksLNK82yyqZacB01m3F/07w+Womf7gC9 1nGw== X-Forwarded-Encrypted: i=1; AJvYcCXk1Ca5rB27+1NcNE3t1eFIYwnDlotfO+jvRt5J4nOaNS4fq1ek1/hSb7lB6Z0tbZB+mMTEcshjBII=@lists.php.net X-Gm-Message-State: AOJu0YxGMk1eHORoWZqUZqUcK5Q2pOjTjxvV1C/zKZLwPLE9p/r/315y LYSeXPZcPuOJlBQ7UPBZa9NSmuyoNin/AQAaKe4S30DkKT/IJDUesXT/DT7huoGaZsZexnsWEph yPnpMijum192mKkju5jphtB4aALmCkT75fN4NoT/lSoXtRf3P2dTg/Bqxtempi43fBtETOpqDR3 rO+gKgZnIKnIYnAgM58Zjpo+poBbarRw== X-Received: by 2002:a05:6122:3187:b0:4f5:28e3:5a5a with SMTP id 71dfb90a1353d-5032d3cdb9fmr12740818e0c.4.1726577849818; Tue, 17 Sep 2024 05:57:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFghaiDxs7hIhzj5ag5jcoLHVUd7wPCfTYZj9GS7+ZtRcGbDBcbQSr8NkKzGGbatzUa1OqSD9XP4UTPS3v8LOw= X-Received: by 2002:a05:6122:3187:b0:4f5:28e3:5a5a with SMTP id 71dfb90a1353d-5032d3cdb9fmr12740793e0c.4.1726577849437; Tue, 17 Sep 2024 05:57:29 -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: Tue, 17 Sep 2024 14:57:18 +0200 Message-ID: Subject: Re: [PHP-DEV] Zephir, and other tangents To: Mike Schinkel Cc: Hammed Ajao , PHP internals Content-Type: multipart/alternative; boundary="00000000000064ac9b0622503bba" From: adam.zielinski@automattic.com (Adam Zielinski) --00000000000064ac9b0622503bba Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable > 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 time, > > 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 Word= Press 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 time, Exactly this! With WASM, WordPress would get access to fast, safe, and battle-tested libraries. Today, we're recreating a lot of existing libraries just to be able to use them in PHP, e.g. parsers for HTML [3], XML [4], Zip [5], MySQL [6], or an HTTP client [7]. There are just no viable alternatives. Viable, as in working on all webhosts, having stellar compliance with each format's specification, supporting stream parsing, and having low footprint. For example, the curl PHP extensions is brilliant, but it's unavailable on many webhosts. With WebAssembly support, we could stop rewriting and start leaning on the popular C, Rust, etc. libraries instead. Who knows, maybe we could even polyfill 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 to = stay relevant. There's an exponential advantage to building a library once and reusing it across the language boundaries. A lot of companies is invested 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 towards 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 sandboxed filesystem. Perhaps we could even create a secure enclave for running composer packages and WordPress plugins without having to fully trust them. 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 assume for a moment there is a ultra low overhead JavaScript runtime in WebAssembly. 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 may= be they would be helpful: - WebAssembly runtime built in PHP (!) https://github.com/jasperweyne/unwas= m - WebAssembly runtime as a PHP language extension: https://github.com/veewee/ext-wasm - WebAssembly runtime as a PHP language extension: https://github.com/extism/php-sdk [1] https://github.com/WordPress/wordpress-playground/ [2] https://github.com/WordPress/wordpress-playground/tree/trunk/packages/php-w= asm/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/87afea1f9a244062a14aef= f3949aae054bf74b70/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/WordPress/As= yncHttp/Client.php [8] https://security.snyk.io/research/zip-slip-vulnerability -Adam --00000000000064ac9b0622503bba Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
> To summarize, I think PHP would benefit from:
>
> 1. Adding WASM for simple low-level extensibil= ity that could run on
> shared hosts for things that are just= not possible in PHP as described a
> few paragraphs prior, a= nd where we could enhance functionality over time,
>
> 2. Constantly improving PHP the language, which is what you are sole= ly
> advocating for over extensibility,
Hi Mike,

I=E2=80=99m Adam, I'm building WordPress Playgro= und [1] =E2=80=93 it's WordPress running in the browser via a WebAssemb= ly PHP build [2]. I'm excited to see this discussion and wanted to offe= r my perspective.

WebAssembly support in PHP core = would be a huge security and productivity improvement for the PHP and WordP= ress communities.

> To summarize, I think PHP w= ould 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
> fe= w paragraphs prior, and where we could enhance functionality over time,

Exactly this! With WASM, WordPress would get access t= o fast, safe, and battle-tested libraries.

Today, = we're recreating a lot of existing libraries just to be able to use the= m in PHP, e.g. parsers for HTML [3], XML [4], Zip [5], MySQL [6], or an HTT= P client [7]. There are just no viable alternatives. Viable, as in working = on all webhosts, having stellar compliance with each format's specifica= tion, supporting stream parsing, and having low footprint. For example, the= curl PHP extensions is brilliant, but it's unavailable on many webhost= s.

With WebAssembly support, we could stop rewriti= ng and start leaning on the popular C, Rust, etc. libraries instead. Who kn= ows, maybe we could even polyfill the missing PHP extensions?
> 2. Constantly improving PHP the language, which is what yo= u are solely
> advocating for over extensibility,
<= br>
Just to add to that =E2=80=93 I think WASM support is importa= nt for PHP to stay relevant. There's an exponential advantage to buildi= ng a library once and reusing it across the language boundaries. A lot of c= ompanies is invested in PHP and that won't change in a day. However, la= cking access to the WASM ecosystem, I can easily imagine the ecosystem slow= ly gravitating towards JavaScript, Python, Go, Rust, and other WASM-enabled= languages.

Security-wise, WebAssembly is Sandboxe= d and would enable safe processing of untrusted files. Vulnerabilities like= Zip slip [8] wouldn't affect a sandboxed filesystem. Perhaps we could = even create a secure enclave for running composer packages and WordPress pl= ugins without having to fully trust them.

Another = use-case is code reuse between JavaScript and PHP. I'm sceptical this c= ould work with reasonable speed and resource consumption, but let's ass= ume for a moment there is a ultra low overhead JavaScript runtime in WebAss= embly. WordPress could have a consistent templating language. PHP backend w= ould render the website markup using the same templates and libraries as th= e 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 maybe they would be helpful:
- WebAsse= mbly runtime built in PHP (!) https://github.com/jasperweyne/unwasm
- WebAssembly runt= ime as a PHP language extension: https://github.com/veewee/ext-wasm
- WebAssembly runtime= as a PHP language extension: https://github.com/extism/php-sdk


-Adam


--00000000000064ac9b0622503bba--