Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:114763 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 99695 invoked from network); 7 Jun 2021 10:26:18 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 7 Jun 2021 10:26:18 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B7AB0180384 for ; Mon, 7 Jun 2021 03:40:47 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 7 Jun 2021 03:40:47 -0700 (PDT) Received: by mail-lf1-f53.google.com with SMTP id f11so25363446lfq.4 for ; Mon, 07 Jun 2021 03:40:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=jZYRYOCsX5YZx9TmP102A+VFwDFhVGQtUrzXdePETpk=; b=smyXIwT7PDgXGMolt07Db8o/AZzue2F4RRKRBECQAxLvfTG+uJ7H42vG9Lb52UdlzJ 4y/9OxsKUcuZ3yHzwLygFAO+0VslCYQWSILcXV+3sSlmSya6bvSRzkIGdAkXpRk0HPSd 1WlZq00zbQwwjnN6c9nJm8nHLohxxkKIQbOunL0sIOEN4uLneRd9Xa5BZ863YsEm4S7U p5ha8kS/HoElI3Qr7+lRr7mqkyZH3y8Hlx9ahQs0lutKOek93B3fRbXEyryXfHhy18tu R4mNwlaOSJ83TwSgx/e4gVhvnvwUhNuggquQfvVW6wGcC8IbjEKUYsdyxehilOS82lSH BuCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=jZYRYOCsX5YZx9TmP102A+VFwDFhVGQtUrzXdePETpk=; b=HdGGDyJcn9rTMNnVTUQqdFYfj9GN8SQyjDh3LfqdTDl1BBt/GkH9epgErhuZfJUxz0 n7SarKYUGghoAokFPawEG1/ANQbQe/pZci0Hcucc0JNdC10LNrZxn91Oqd6TpNKDQqix QDrODsUtRulK0ylgZMyI9RuSlbGXklyTW0l73ltc/NHfwnACazmTISMYJmJxK28Mp5y/ iU5WsrDohFXu76PkJu+1E7ybzhaDoOwCLxKtKeAXw+MePui/4yqmV4LdhRM5pwooi3F7 FCfovVgH7274S3qmZStC8IlhluWp7cNy3Td/Dx6ctkag6cWDPbmYo95kR7iLlCBAHUmz /5Yg== X-Gm-Message-State: AOAM533tX9nmDnig0Zz6NEbNoOePi3J5bPIc7cvJRK1Pfss4TYdRmjiw bs/UuXzPCLdvtUchO9BqYygdwS3knTRkZkSof7lYriNkE8GSmQ== X-Google-Smtp-Source: ABdhPJyR7FPMvyaJyLuc/dUOBK4isl16OhCVSjVMnEeYkAt2Yz2tvQLkl9ndSx615A/9Gh2APzxy1JZ4TQmRmA0OYVY= X-Received: by 2002:a05:6512:acd:: with SMTP id n13mr11574702lfu.485.1623062443905; Mon, 07 Jun 2021 03:40:43 -0700 (PDT) MIME-Version: 1.0 References: <6D61A2FD-DC80-43A5-81C2-FB19F9CB5078@dafert.at> In-Reply-To: <6D61A2FD-DC80-43A5-81C2-FB19F9CB5078@dafert.at> Date: Mon, 7 Jun 2021 12:40:28 +0200 Message-ID: To: Mel Dafert Cc: PHP internals Content-Type: multipart/alternative; boundary="0000000000006ad65405c42aac95" Subject: Re: [PHP-DEV] Policy for procedural style in new additions From: nikita.ppv@gmail.com (Nikita Popov) --0000000000006ad65405c42aac95 Content-Type: text/plain; charset="UTF-8" On Thu, Jun 3, 2021 at 8:28 PM Mel Dafert wrote: > Hi internals, > After the RFC to add IntlDatePatternGenerator () was accepted, it was > brought up that the duplication of > procedural and OO style was not necessarily/useful anymore. > This already has some (old) precedent - in 2012, UConverter was added to > ext/intl > (https://wiki.php.net/rfc/uconverter) and in 2014 IntlChar > (https://wiki.php.net/rfc/intl.char) - both of which only provide a > class, but not the > procedural API. > This was also shortly discussed on the mailing list for IntlChar: > https://externals.io/message/79146#79167 after which the procedural API > was dropped without much ado. > > When I wrote the IntlDatePatternGenerator RFC, I was not aware that the > procedural API was viewed as deprecated, nor that there had been additions > to > ext/intl that were purely OO. > In the thread after its vote, it was also suggested that we add a policy > that > forbids new additions from adding duplicated APIs, and that OO style should > be preferred if possible. I am not sure if I am the best person to write > such an RFC, > but I wanted to bring this to its own thread and provide the context I > have dug up so > far. > > The duplication of the OO and procedural API dates back to the addition of > the intl > extension to core. There is some discussion about it in this thread from > 2008: > https://externals.io/message/36775 > (ignore the unrelated discussion about PHP6) > The main argument at this point was that OO in PHP is a new thing, and > that while > the OO API is objectively better, the procedural API should also be there > to > lessen the learning curve for existing PHP users that are not yet familiar > with OOP. > I would argue that 13 years later, this argument no longer holds - anyone > who > has used PHP at some point since then most likely has encountered classes. > > One open question that still remains is what we do with the already > existing > procedural API. > Should it be deprecated? Should it only be soft-deprecated, in that we > mention in the > documentation that the OO style is preferred, but that the procedural API > is > not planned to be removed? > Should we just leave the procedural API as-is and live with the fact that > some > classes have procedural counterparts > and some don't? > I would personally lean towards (at least soft-) deprecation just for > consistency, > but I would like to hear what you would have to say. I think that not adding new procedural mirror APIs is pretty uncontroversial at this point. I think one open question is regarding API additions to existing classes with a mirror API -- should we keep adding procedural functions in that case? The more interesting question here is whether we want to deprecate existing APIs. From a quick look, these are the extensions that provide procedural mirror APIs: date finfo intl mysqli oci8 (only partially) xmlwriter I don't think I'd want to blanket deprecate all of these. I do see value in some of the procedural APIs (okay, only date really) or at least historical importance (mysqli is a migration target for mysql, which was only procedural). I think if we want to deprecate these, it should be on a case-by-case basis. For example, I see very little value in the procedural intl APIs. One annoying factor here is that these mirror APIs were often added thoughtlessly and have design issues as a result. For example, xmlwriter_open_uri() makes sense, but XMLWriter::openUri() should clearly have been a static method, not an instance method. Similarly, mysqli_init() makes some sense, but mysqli::init() is entirely useless. Regards, Nikita --0000000000006ad65405c42aac95--