Re: Note added to rand

From: Date: Mon, 10 Sep 2001 11:58:41 +0000
Subject: Re: Note added to rand
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-65653@lists.php.net to get a copy of this message
> No number is truly random. That is the nature of computers. You > can only generate a sequence of numbers, based on a seed. True (of course, I knew that already long ago...), but 1) You can obscure that by using time-varying seeds in order to get seemingly random numbers 2) You can resort to lavalamps, radiosources, monitoring mousemovements/keystrokes, etc etc > My god, this is generating a random number, its nothing that > complex, so lets not make it such. And, btw, if you want to use lcg, > just use the lcg_value() function. Creating a language that is easy to use is very complex. It is very easy to create a language that is hard to use. That was and is my whole point. lcg_value() is another strange duck in the bite: it seeds itself automatically on startup, you cannot seed it yourself, and you can only get it to return rand() / RANDAX, not a integer range (the alg. returns integers!) > We don't need PHP to support 15 different algorithms for generating > random numbers, if you want that, move it into a php extension, but > it doesn't belong in the core. But IMHO the interface needs to me facilitated in the core, otherwise you can't use other RNG's like you can use the core ones. There are 3 different RNG currently in the core! > > My proposal reduces the namespace-load to PHP to 2: random and set_random. > > If you want random numbers, you only have one function: random. If you place > > set_random at the top of any script, you will see that it garantees that the > > script will act identically on each call, because set_random controls all > > random! > > > > IMHO the power of PHP is it's intuitiveness in using it, and I don't think > > mt_srand(); mt_rand() is intuitive. > > > > Really, then why hasn't anyone complained as of yet? And this is the > way it is done in other languages as well (C, Perl, Python). Why > change what's working? If you really want, create a new extension, > distributed externally, just like Perl has the Math::TrulyRandom > module. Most people don't realize it is unnecessarily cumbersome. If you look at newbies code, you see they make all kind of mistakes in it, which would IMHO be reduced if it becomes simpler. > > > > Please understand me right, I find it very useful to have someone > > critically > > > > look at my proposal, but please be more specific. > > > > > > > Right, those more specific comments belong on list :) > > > > I didn't Cc to php-dev, since I could be breaking the law... but you may > > forward this mail to it :-) > > > > I am. ;) > > -Sterling > --Jeroen

« previous php.dev (#65653) next »