Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:112564 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 89964 invoked from network); 20 Dec 2020 14:37:37 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 20 Dec 2020 14:37:37 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AD9661804DD for ; Sun, 20 Dec 2020 06:09:49 -0800 (PST) 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-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (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 ; Sun, 20 Dec 2020 06:09:49 -0800 (PST) Received: by mail-lf1-f47.google.com with SMTP id h22so7871621lfu.2 for ; Sun, 20 Dec 2020 06:09:49 -0800 (PST) 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=92CH8xk3epQhkt+m+WZpKakvManELJkbk0w+/5Q8j18=; b=AaqEIDgfNLBwOCKl2Nei9PTp1NuWUscg+w224BbJtN9jnPe0vnEuLcx7Bw5dlQHmwW zzkO+b48IWZoKGcQA4g9Hc/hgKUaPBQH/PLWAtis7JiqMeMS0jqBMnw0wtFjKksuVcBZ nX7Lre6D14g28umlRB4xpFi8OMp/iA/Ab1eQ8m0bQSIc5uZ35giFqxiCiu64WIrIXR9v zWMnrP24RXag0F+bTx+l7hJUIrVFvP/tbUzCZMzr18Ks3P1qMWUi04Pb/Q265HXoiD/u 1/D0vJbXaAl1sp0Rqda7p/UQCBYwZPjVOtD6Mf5BF1dNNS9Orh/qSpL27RpzrImzpUKD HQNg== 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=92CH8xk3epQhkt+m+WZpKakvManELJkbk0w+/5Q8j18=; b=jnpBpvhqbFHWZJvWGwF22ONNn8w0UdQZsgGiAVKctsWc3iO5RM3gaHscQ3HUeNrecN KGOdCpDNFn44+JI5fm577shUCJ8QlXa6/8J9/JwBhFtD3CstofSOx/SD768JpDVlT7ej pQnAs0FrCLITO+P6bSqE3FPnn1DHYLYX3WMfiMVuE5B3vYGaWU+QOHIxsq6WahBXaCsA b9oam+gpv/B8j+aiwOMfuoVOVY23Sn1sq1M6IXpiCdqGZ05uwbjwdCuBWcrDRinR4Gh/ wCqIsw4xuAIaiiIXggdxk5P4HDwK/bm11SQhKQkgrQ0lKJtZ3oTsmJvulCdA5wFIid0M xl0g== X-Gm-Message-State: AOAM5335o4fDtFJWsNbfbxq8jSQhQSw+8FKitO8BA/CWyevFEQ7TbqJz mkTySqgluEctg5M3b+cL1WagxzktCRW9IiWwqQk= X-Google-Smtp-Source: ABdhPJwYIsTSZTIS1LGjm2LuJrYyvOyopGogekwo2WisW08awMrIulCJIeLfBzkaDcXS047foHiA3EYCdXRKf6xsL/M= X-Received: by 2002:a2e:b00c:: with SMTP id y12mr5290260ljk.85.1608473387780; Sun, 20 Dec 2020 06:09:47 -0800 (PST) MIME-Version: 1.0 References: <1f319ee0-e5e2-3d5e-2b8c-4d3c073f98e6@gmx.de> In-Reply-To: Date: Sun, 20 Dec 2020 17:09:36 +0300 Message-ID: To: zeriyoshi Cc: "Christoph M. Becker" , Internals Content-Type: multipart/alternative; boundary="000000000000e8ce8305b6e5e484" Subject: Re: [PHP-DEV] Re: Improving PRNG implementation. From: maxsem.wiki@gmail.com (Max Semenik) --000000000000e8ce8305b6e5e484 Content-Type: text/plain; charset="UTF-8" On Sun, Dec 20, 2020 at 6:45 AM zeriyoshi wrote: > Thanks cmb. I have created a first draft of an RFC. I think I've covered > all the necessary requirements, but I'd like to know if there are any > problems. > https://wiki.php.net/rfc/object_scope_prng A few IMHO comments: * Namespaces are controversial. There were multiple discussions and RFCs about introducing them for new functionality but nothing came out of it. Still probably worth adding an option for \PHP\PRNG to the vote, or something like that. * The "Which set of PRNGs should be provided as standard?" vote seems vague to me. Are you proposing to add only one algorithm? Why? Also, the adding just interfaces option makes no sense because there's Composer for things that don't require a C implementation. * "One possible solution is to implement the PRNG in pure PHP. There is actually a userland library [1], but it is not fast enough for PHP at the moment. (However, this may be improved by JIT)" - this definitely needs a comparison because implementation in C is only needed for performance reasons. * Method names: you don't need to emulate the conventions from non-OOP code, e.g. string_shuffle() --> strShuffle and array_rand() --> arrayRand(). Use a more naturally readable convention like shuffleString(). * The return value in "function shuffle(array &$array): bool" means that if something goes wrong, callers will have no idea what it is. Just throw an exception. * If the classes are namespaced, don't prefix their names, e.g. PRNGInterface --> RandomGenerator (yay, so many opportunities for bikeshedding!) * Perhaps it's worth mentioning other languages using this pattern, e.g. Java[1] and C#[2]. * Do you have evidence of widespread demand for this functionality? Usage statistics for the userland implementation you mentioned[3] don't look that hot. ------ [1] https://docs.oracle.com/javase/8/docs/api/java/util/Random.html [2] https://docs.microsoft.com/en-us/dotnet/api/system.random?view=net-5.0 [3] https://packagist.org/packages/savvot/random --000000000000e8ce8305b6e5e484--