Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:124671 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 CE6871A00B7 for ; Mon, 29 Jul 2024 04:11:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1722226416; bh=TRgVTH8NFf1Lm8G63Afcm6SiMIAurllFNRc4JBf54NM=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=VYwc2PmqthCTv7/ZIAk0bnTp5mWLLeJUWFQLnCsbhoNAdrdltFtevGOi+n9/5HUSi m1rXw1WLf9xZxuEOldIfxETjzuD31OQpjiZrkcfstP4cBDjpBVbxmunGJFzBuZN+Ez 0GoHUvkUtjQ3Lk7WnmRQ3VHi2tKoP6nUmPTWRj7p5oo1T+uXV70gE0SU2f4TZ+i/w6 R/I2qJsVikPn6KQa7jlPH70KTQX7CBX9wgrNuuMOXjrB5HoKItutA3MPz7SoA/xXzm ZXfxqPM6Rtu0KcMs5EGcR3i9o7KdAsUkmbWJ27uOeJ+udP91NjHMmegF60lmvdleqf wRoKvoseYCqzg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 601F318003E for ; Mon, 29 Jul 2024 04:13:35 +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-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) (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 ; Mon, 29 Jul 2024 04:13:34 +0000 (UTC) Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-67b709024bfso14661467b3.3 for ; Sun, 28 Jul 2024 21:11:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20230601.gappssmtp.com; s=20230601; t=1722226317; x=1722831117; 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=rz6RWI16N51a4g0UsbouxFDlvSW7aDo4/6Ycy/MYt/E=; b=Xd+uxOD5rVfNWCUqlrw+zVRulwqORYWhF8bmX14GAfpc3WutK+IQKbmHJtEeEtVRZe zcjm+p8KeQD4zzKzCk4dDohNkMQnZwt1eeO9Vdi88uWNQBxKRGwhY1G0s1z4DLTkWFyq ukd8KCFssyA35vdLnpvSJhJoWJVd/gKUO6fB2cFjnnbZ6vFA1DQICpYgZjoURo4rK3ZC 37dXSBnTMPAAJVmYS0ElzfyJFZ2NLH17S6kEn5UyV7+D8nTqcOWEoeYXqMJQTtcGuW5+ V5tWUvo0EZFZUMCkEFj3dcitVM9RYn7iCBHU9CAI12x9NDS8XytokjPp9DyBpM/HN2mz 9Scw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722226317; x=1722831117; 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=rz6RWI16N51a4g0UsbouxFDlvSW7aDo4/6Ycy/MYt/E=; b=YcHYYBXjpY/0qm/c/8zsP0zx8Kohr/FAkvDu+42T+d/VRtmWVzGCREJgS8p82ptFxt dzyvxCcIzNV2DbeKviZS3hbXIH8p0r5k6jdGyalQeFVTTmrMPMSx/4UbsHea1McVqOF1 LIESPfph1NkfR3Ldt9S8Xy9rmQkKQNlnvTeY03C8ukpkxDmc6sac4gPd4hc27YZx9Jpr jkwbomeGILnvo9vzbw2cNzcWlZHuiUUak1pgi2eKSCeis4kWFXl0pEpSOhpbCA9m9kYS 2BhXdKiaSS4BFnLENtHBgh0KVEiIDMA85OTJJ3rWpkuf2vNrJ95WSLdQFc+tEujZU3gp fP6Q== X-Gm-Message-State: AOJu0Yz9DnQ8TDCYBcFQzSyn5AxqfHGvnAgj/Uv9Mrotre33spsDgQFu pilkgk+nOkUVgMrSvs0+QyF9qyHwBx20SKBl0bu+bFJ+wQGLXUim2ZcLZWqfwQwgOKLZYmr+2iL AnsQ= X-Google-Smtp-Source: AGHT+IHtqLCesNQxRM/ZJILHfcV6R+PTYwEoeA5MmIA6ciS5QZvRwY9vHUi3qKxPPIMx/PVRVgOkLQ== X-Received: by 2002:a05:690c:74ca:b0:631:78a1:bb5 with SMTP id 00721157ae682-67a09f4aa62mr78165187b3.35.1722226317000; Sun, 28 Jul 2024 21:11:57 -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-675681123f9sm18862297b3.63.2024.07.28.21.11.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Jul 2024 21:11:55 -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.8\)) Subject: Re: [PHP-DEV] [RFC] [VOTE] Deprecations for PHP 8.4 In-Reply-To: Date: Mon, 29 Jul 2024 00:11:54 -0400 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: <62608356-9A91-48AD-BAE8-9BED233BB715@newclarity.net> References: <1a88918e-e808-d778-45e1-53797660e093@php.net> <3563cf9b-8eab-4c82-b525-a5d2f9a767bb@varteg.nz> <38920A4B-790D-48C7-B2F6-C49D3F506232@rwec.co.uk> <951AA94A-8C07-446E-925C-15BB97F146A4@newclarity.net> To: Morgan X-Mailer: Apple Mail (2.3696.120.41.1.8) From: mike@newclarity.net (Mike Schinkel) > On Jul 28, 2024, at 9:19 PM, Morgan wrote: > I, too, wish there was more willingness to add useful functions to = core.=20 :-) >>> On Jul 27, 2024, at 6:14 PM, Morgan wrote: >>> Why a SHA2 algorithm? Why not a SHA3 one? How about standalone = functions for both, and then when SHA4 comes along (as it inevitably = will) another standalone function for one of its variants? >> Yes. Yes, And Yes. >> And ideally within a `\PHP` namespace. > At that point you've got \PHP\sha3() instead of hash("sha3-?"), and = now you've (a) lost the word "hash" indicator of what's going on, and = (b) hidden the choice of "?" from the user. I'm not really seeing an = improvement. Well, your comments are based on assumptions that they would have to be = implemented as you were envisioning when you wrote your reply.=20 My "Yes. Yes. And Yes" was not intended to be full RFC that fleshed out = all the considerations and proposed a specific implementation. IOW, = there are definitely ways to address your criticisms if we are = open-minded in what could be considered. :-) > At that point you've got \PHP\sha3()=20 I'm sure you will find it ironic in hindsight like I do that you chose = `sha3` (vs. `md5`) as the function to illustrate your argument about not = having the word "hash" given how SHA is an acronym for "Secure Hash = Algorithm." :-) By the same token, we could complain about how parse_url(), urlencode() = and urldecode() all lost the word "resource." :-o Seriously though, some acronyms are well-known enough =E2=80=94 or = easily discovered enough =E2=80=94 that we should be able to use them as = function names without lamenting they are not spelled out. But if the concern is they are not grouped together as hashing functions = than =E2=80=94 had we had a `\PHP` namespace as an option =E2=80=94 we = could easily have:=20 - \PHP\Hashing\md5() - \PHP\Hashing\sha1() - \PHP\Hashing\sha256() - \PHP\Hashing\sha3() - etc. Also, there is no reason we have to be exhaustive. The pareto principle = is always one we should consider when deciding when anything should be = elevated to having its own dedicated function. > instead of hash("sha3-?") The problem here is semantic information is encoded in a string rather = than in a named symbol and thus is not recognized in the AST when = parsing and requires a hack of diving into the string in order to = validate.=20 So typically, no type checking, no auto-complete, and potentially = delayed error detection. Using strings where symbols would be better is a common wart in PHP =E2=80= =94 such as PHP not having a first-class type for class, interface or = function =E2=80=94 so we have to pass around names as non-typesafe = strings instead. =20 BTW, I asked ChatGPT to opine on the problems caused with = strings-as-symbols from computer science and software engineering = perspectives, and this is what it gave me: https://chatgpt.com/share/17d57881-c411-4b64-863a-d0692b4a4577=20 > and (b) hidden the choice of "?" from the user. I'm not really seeing = an improvement. What's wrong with something like? use PHP\Hashing\sha3; use PHP\Bits;=20 ... $hash_224 =3D sha3($data,Bits::224); $hash_256 =3D sha3($data,Bits::256); $hash_384 =3D sha3($data,Bits::384); $hash_512 =3D sha3($data,Bits::512); The point I am trying to get across is that improving the developer = experience is not a binary true or false endeavor. There are many ways = to improve DX, but they all must start with a openness to consider doing = it. > On Jul 28, 2024, at 9:19 PM, Morgan wrote: >=20 > Hey, all I'm doing is pointing out that the only reason those = functions were standalone to start with is because when they were added = they were the only ones around; they weren't introduced as "easier to = use" alternatives to the more generic case. If hash() had been added in = PHP with half a dozen different algorithms right at the beginning, would = md5() and sha1() have been given special treatment? Possibly: MD5 (and = later SHA1) got all the publicity at the time. >=20 > I haven't seen an explanation of what makes them "easier to use": if = you want to use md5() (for whatever reason: I don't care) it's not that = hard to write hash("md5") instead. I just went through a file = deduplication utility of mine and did exactly that. Yes, I am using MD5 = as a message digest algorithm. But just because they were historical artifacts doesn't mean that they = should be frowned on, or removed. `echo` is also a historical artifact, = but no one is arguing we should get rid of this: echo "Hello World"; And then require developers to use this instead: fprintf(STDOUT, "Hello World");=20 =C2=AF\_(=E3=83=84)_/=C2=AF -Mike