Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125635 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 057C11A00BD for ; Fri, 20 Sep 2024 05:20:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1726809777; bh=IKNHpk9tfLVlX/iq8Lj98M5QH067nqyTxziP7U2v7wQ=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=Fc/zSkNRu40jYtvtdA/ntIkzl6lBaGEMZach/Sg3ugYaF2ZCmKeCkV5tlbJi94YX0 mfewjOqNJC9VQs50rU/utRqBLYbPGZPBroKfW+pEZo1gFFQ35Ky/t7ZCsskyvlhpoJ MRr3ZBV8IeLxS+1baci7pHItUs/m85M2U24B2HLkp2Fg3nNtst4wzCcI9E1VXpyHvo 4RfWx/73Gz9fCHGGCkLTDm2nXncyS3r4YAJKTeiqSKtUy8pJXsIeFQz44pn1o7MCgJ CB6Lg7IkdE2TPH17g0XQOplbIn0iBrOt/V0zIo3KwULQiGuR+UdRu3gptNkYGjvR61 Kp+6Kraf51jNw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 37B9F180042 for ; Fri, 20 Sep 2024 05:22: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=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-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.177]) (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 ; Fri, 20 Sep 2024 05:22:55 +0000 (UTC) Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-68518bc1407so15692677b3.2 for ; Thu, 19 Sep 2024 22:20:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20230601.gappssmtp.com; s=20230601; t=1726809648; x=1727414448; darn=lists.php.net; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=qzD53abk4Q6rFIJtPeFS8bvWlNn6ZFCWfDeYiO2+ExI=; b=afFZXtZrlAyZSACOr+/GnXJXFatI7LoziJ7AmK/3aH+f36oHa04HbyxfkLAcFpzwsI NSjxPta6MJ9qhjq6gX8fFfptLRXL6pZ0nAP2DJIa60sPAlM5pgA0Nf9QwbhhnPAKGYoJ FC4zd6m2V9onUXqnr0IaLLVZcEB1pwUYbJwQ08YwqNTyimFEEHKhkZqdNLU94F/+OA5r ldBNbaqVpLEcCfEwILGuLy+nKOMX0i2xlcZtzVQvSuBOOW59qzQqKXS2bxuw5soqZDrr +T06V0lshOGA2/WHTwOb+3qe9NTATJPxkHV6MEHU7qORQ6eHywFAjXcWQow2P2WXBmIn eRGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726809648; x=1727414448; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qzD53abk4Q6rFIJtPeFS8bvWlNn6ZFCWfDeYiO2+ExI=; b=GwZ1TCJM2CoOOmboW7yWcMG3nv7s1aI249YJBOIE51zUrNMjCw4HrNOuYJRuhWhCmn xCyfPMmpjzcaGWc3ZyZLy+Q2QXGNy+8BB64AavC1h1C47D7uXHQ9KtQnyw9BSluhBNh8 fuGzMwUtlftjQAtduN4UMx1wTmbLfYzQp6tsjLQBE24YuiPzQ6wwIbS+zdaix7MocR9W MZpLiyi7RYede4uk+72HINNcTh3XYA5GHaHG76n19+Ya39JIxzwVp7zVA+7yZ2+UVnK6 I1hTc4qhbvV44BBITu9CgKq8V1CFAjo5Zc7moeFW6EX0YCoEY7fVB/aUfyEXmlQwhyTr 9FZA== X-Forwarded-Encrypted: i=1; AJvYcCW4e9HieqXP40MFlh62//H4rkeRG6YNOenoIqZhxa2bN+FdKu0t9+N6I/65vrhgbO9t2W4KYz14Bt0=@lists.php.net X-Gm-Message-State: AOJu0YxJpbQbtU6GJ8Sis6W9iBqIOg7mejO8cqDrlf3r4zYvslzI/KAd pEwp9J0/8IrXLAwyHfeDGug/oLin3e75TFwKqF7bpBmJtBoEzXF6pmvMKlJcc+A= X-Google-Smtp-Source: AGHT+IG7CnioXXpD6PjbH0MxKa0Iofdlseqjp3TZmA8VIk2/l8y9AvBpv5Ok/wReWNGUz/8AwqXAGA== X-Received: by 2002:a05:690c:39a:b0:683:37a8:cd77 with SMTP id 00721157ae682-6dfeeed10aemr17261937b3.29.1726809648364; Thu, 19 Sep 2024 22:20:48 -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 00721157ae682-6ddfa73bccesm8661797b3.72.2024.09.19.22.20.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Sep 2024 22:20:47 -0700 (PDT) Content-Type: text/plain; charset=utf-8 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: Re: [PHP-DEV] Zephir, and other tangents In-Reply-To: Date: Fri, 20 Sep 2024 01:20:46 -0400 Cc: Adam Zielinski , PHP internals , Dennis Snell Content-Transfer-Encoding: quoted-printable Message-ID: References: <8D420123-4ECF-48FD-A9C3-F80C60457A37@newclarity.net> To: "Rowan Tommins [IMSoP]" , Hammed Ajao X-Mailer: Apple Mail (2.3696.120.41.1.10) From: mike@newclarity.net (Mike Schinkel) > On Sep 19, 2024, at 12:00 PM, Rowan Tommins [IMSoP] = wrote: >=20 > On Wed, 18 Sep 2024, at 20:33, Mike Schinkel wrote: >> Yeah. That was the original goal. >>=20 >> But to say WASM's domain is limited to browsers is not valid any = longer: >> [...] >=20 > While it's definitely interesting seeing what uses it's being put to = beyond the browser, the majority of those articles are talking about = using WASM on its own, in the kind of places where you might use a = container, to host things like microservices, serverless functions, etc. Sigh. I did not include all potential examples. Leave it to you to limit = your characterizations to only the ones I included.=20 Here is another: https://github.com/wasmerio/wasmer-php > Embedding it into other languages is a different usage again. It's = certainly something that is being explored, e.g. by Extism, and that = seems like a good project for anyone interested here to participate in, = e.g. to help design the "glue" between PHP and WASM / Extism. Moot point as it cannot be run on a managed hosted server. https://github.com/extism/php-sdk >> WASM's ability to run on a managed server =E2=80=93 assuming it were = built-in=20 >> to PHP core >=20 > Just to reiterate, if by "built-in to PHP core", you mean "every copy = of PHP includes a functional WASM runtime", that's not going to happen. = It would mean bundling (or requiring every user to install) a huge = third-party dependency, with all of its dependencies and platform = requirements, even if they weren't interested in using it. So why do you claim that bundling a third-party dependency is a "never = going to happen" scenario? =20 By that logic PHP would have none of these functionalities: =E2=80=A2 cURL =E2=80=A2 GD =E2=80=A2 PDO =E2=80=A2 OpenSSL =E2=80=A2 MBString =E2=80=A2 Zlib =E2=80=A2 Zip =E2=80=A2 XSL =E2=80=A2 EXIF =E2=80=A2 BCMath And PHP would be much less useful without any one of them.=20 > The only runtimes where WASM is ever going to be available "out of the = box" are those already built on a JavaScript engine (usually V8), like = node.js, Deno, Electron, etc. The WASM is then running inside the = existing runtime, not a whole new VM - like running Scala and Java code = in the same JVM; or Hack and PHP in (older versions of) HHVM. Seems you do not actually understand WASM runtimes. =20 While WebAssembly is available "out of the box" in JavaScript-based = runtimes like Node.js, Deno, and Electron, it is not limited to them. = Standalone WebAssembly runtimes like Wasmtime and WAVM allow WebAssembly = to be run as a general-purpose compute target, outside the scope of a = JavaScript engine.=20 > On Sep 19, 2024, at 4:41 PM, Hammed Ajao wrote: >=20 > Shared hosting for php gets you the worst possible version of php. = Can't recompile to enable any bundled extension, can't install any new = extensions, so how exactly would you approach this? Wasm bundled with = the engine by default? Or some kind of opt in mechanism that shared = hosters won't even be able to use? To be clear, shared hosting and managed hosting can be VERY different = animals.=20 I am advocating for enterprise-level managed hosting =E2=80=94 like = Pantheon =E2=80=94 not shared hosting like GoDaddy. > On Sep 19, 2024, at 4:12 PM, Hammed Ajao wrote: > On Wed, Sep 18, 2024, 1:33=E2=80=AFp.m. Mike Schinkel = wrote: > But to say WASM's domain is limited to browsers is not valid any = longer: >=20 > I don't know where you got that since I never said anything along = those lines. You did not say that explicitly, but you strongly implied it. Had you = not meant to imply it then you'll argument would have made little sense = because you would been implicitly admitting there are other uses for it. > But since you have all those guides and it's so practical, what's = stopping you? You'd do a better job of convincing me with a MVP than = some random blog posts. Here you go: https://github.com/wasmerio/wasmer-php BTW, as you being a C++ developer your argument is rather cynical = because most PHP developers do not have the skills to write PHP = extensions or work with FFI, and it is not a skill that can be acquired = in a few weeks worth of free time. So you saying "Just do it" can be = seen by a cynical person as you attempting to shut down discussion by = presenting a blocking task that you can be pretty sure is too high a = technical bar for most PHP developers. I do want to gain that skill, but I doubt that I will be able to any = time in the near future, especially not with other work commitments.=20 > - https://docs.docker.com/desktop/wasm/ >=20 > You mean the feature that's been in beta since 2022? Yeah that's = exactly what I'm referring to. If docker and all their money and = engineers haven't shipped wasm in 2 years, how long do you think it'll = take a bunch of volunteers? Shipping as a container runtime without the surrounding support of a = host is a bit more complicated than implementing within a host.=20 By your argument Node, Deno, and Wasmer would not have been able to ship = WASM support yet. > You can't do shit on a managed server, that is not the bar at all.=20 Who made you the arbiter of what the bar should be for the needs of = other people? > What makes you so sure that wasm will be allowed on managed hosts? = What's the incentive for providers to allow it? The incentives would be market differentiation and customer demand. For security reasons it does not matter if customers demanded FFI or = extensions written in C, there is simply too much risk. But if there were a sandboxed secure runtime shipped with PHP, = especially one that could be memory-limited and CPU-throttled, then it = would be easy for some managed hosts to decide to enable it. Not all = would, but channeling your imagined role as arbiter, I would say that is = not "the bar." > > Extensions, which are already implemented in lower-level languages = like C or C++, would still need to be compiled to WebAssembly if the = goal were full compatibility. When did I or anyone proposing WASM for PHP suggest that making = compiling extensions into WebAssembly would necessarily be a blocking = requirement? > This might lead us down the path of either creating a domain-specific = language (DSL) for PHP=E2=80=94similar to AssemblyScript=E2=80=94or = simply leaving it up to the library authors to choose lower-level = languages (as is currently the case). Or, simply allowing AssemblyScript as the initial way to use WASM in PHP = core. =20 > > In essence, WebAssembly is great for certain scenarios, but PHP has = existing mechanisms that make the addition of a Wasm runtime potentially = redundant for most use cases.=20 Then for those cases where it is redundant, don't use it. > I hear you, you want to run low level code on managed servers. I would = approach the problem differently e.g. Creating some kind of directory = for `trusted` php extensions, the criteria for what qualifies as = `trusted` would be up for discussion. Or maybe we can bundle a small std = lib of select extensions with core. Those make a lot more sense to me = than adding an entire abstraction layer. Many hosts already whitelist php extensions. That does not help.=20 The use-case being discussed by me and the others who commented in = support of WASM is primarily bespoke code written for project-specific = requirements. I am not saying WASM has to be the thing to meets that need, but AFAIK = there is no other potential similar solution that could address it. You = can dismiss that goals as being unimportant or "not making sense," but = that does not mean there are not those who find meeting that need to = make a lot of sense. Let me turn it around then and ask that =E2=80=94 rather than being the = gatekeeper against a solution=E2=80=94 you instead propose a solution to = address all the following requirements: Ability to run some form of = module/add-in/extension/whatever-you-want-to-call-it in PHP that: 1. Ships with PHP code so those managed hosts who want to enable it can = easily do so, 2. Allows for fully-bespoke project-specific things to be developed,=20 3. Is reasonably easy to program in a secure way (not C or C++),=20 4. Enables near native performance for things like looping and string = manipulation and maths, and 5. And is secure, can limit memory use, and can throttle CPU hogging so = hosts will not object to enabling it. Since you have already dismissed WASM as not the right approach, how = would you alternately address those requirements? -Mike=