6 ms·
The PHP approach seems to be that any crazy behavior is acceptable as long as it's documented.
by mikeash 11y ago
The PHP approach seems to be that any crazy behavior is acceptable as long as it's documented.
- dspillett 11y agoTo be fair, that is not an uncommon situation elsewhere either.
- mikeash 11y agoI think it is. Sure, there are plenty of calls out there in all sorts of systems that have crazy, documented behavior. But it's rare to see anyone outside of the PHP world defending the crazy behavior purely on the basis that it's documented. Crazy behavior is almost always there because of compatibility concerns, performance concerns, or an acknowledged bug that just hasn't been fixed yet. Outside of PHP, I rarely see anyone just say, "It's fine, that's how it's documented to behave" and leave it at that.
- BuildTheRobots 11y agoOutside of php and systemd..... <Friday afternoon trolling is just too easy this week />
- dspillett 11y agoAnd mySQL of old. I assume things are much better now, but I remember a time when things like INSERT <table> (<date_field>) VALUES ('2015-02-30') would not have raised any sort of error, amongst other terrible things that people would defend having to implement explicit checks for in other layers of your application.
- slapresta 11y ago> I assume things are much better now Nope: http://grimoire.ca/mysql/choose-something-else http://grimoire.ca/mysql/choose-something-else
- Spivak 11y agoI'm genuinely curious, what are some examples of systemd's odd behavior?
- BuildTheRobots 11y agoWell, the fact my window manager is now intrinsically linked to my systems boot process strikes me as somewhat obscene. There was the amusement with it reacting to debug being passed to the kernel which caused the system to never finish booting... systemd is by no means alone; in the last month I've discovered that `yum` deliberately breaks its output when you try and pipe it to something else (I mean really, ffs, really?). The justification for this isn't even internally consistent which really winds me up too... Whilst I pick on a couple, there's been innumerable packages, languages and platforms over the years that have had their share of what could politely be called idiosyncrasies. I highly recommend The Unix Haters Handbook [1] for plenty of historic examples -it's a lovely read -oh, and for years one of the *nix bullet points was always "all the power in the world and not a safety in sight" [2] [1] The Unix Haters Handbook: https://en.wikipedia.org/wiki/The_Unix-Haters_Handbook https://en.wikipedia.org/wiki/The_Unix-Haters_Handbook || http://www.csf.ac.at/fileadmin/user_upload/BioComp/training/unix_haters_handbook.pdf http://www.csf.ac.at/fileadmin/user_upload/BioComp/training/... [2] The Hole Hawg: https://web.archive.org/web/20150214132948/http://www.team.net/mjb/hawg.html https://web.archive.org/web/20150214132948/http://www.team.n...
- RickHull 11y ago> Well, the fact my window manager is now intrinsically linked to my systems boot process strikes me as somewhat obscene. Gnome depends on logind, which is sensible. Yes, logind is part of a suite of system management tools which also includes tools to manage the boot process. Your complaint would apply equally to your window manager being intrinsically linked to your serial port (via the Linux kernel).
- BuildTheRobots 11y agoAs an honest question, could you explain _why_ it's sensible? Until a couple of years ago, my linux box was nearly entirely modular letting me install any combination of boot-loader, kernel, init system userland tools and/or desktop. How is this better?
- Peaker 11y agoI recall a Rails bug used to hack github and inject a bugfix commit. The Rails community rejected the fix originally because the crazy behavior was documented.
- pogden 11y agoWhat's more common outside PHP is that functions throw errors or exceptions when given invalid input, rather that trucking along and producing output that is clearly not what was intended.
- peterfirefly 11y agoHow else is it going to unseat INTERCAL?
- vidarh 11y agoFirst it needs a replacement for INTERCAL's "please come from".
- sarciszewski 11y agoThat's not a "crazy behavior", it's a limitation of the algorithm they use. mt_rand() only has approx. 2^32 possible seeds; why would you expect it to support ranges larger than 2^32? The best thing to do is to not use mt_rand().
- skybrian 11y agoIf the user asked for more bits of randomness, they need to generate more bits. They could have chosen a different algorithm, or perhaps called the random number generator twice and concatenated the bits. Scaling up is clearly the wrong thing to do.
- mikeash 11y agoIt also makes me wonder how it behaves for numbers below the limit. I would wager that there's substantial bias in the results if you ask for a max of, say, 2^31 + 2^30.
- mikeash 11y agoI would not expect it to support ranges larger than 2^32, so why does it? Returning garbage when one of your parameters is beyond a certain limit is "crazy behavior." Either support it properly, or don't support it at all.
- Spivak 11y agoIf we were talking about C this would be called undefined behavior. If you don't satisfy the preconditions before calling a function then the not only is the output invalid but the entire program which uses it is invalid too. I don't think a language like PHP, or indeed anything written in it, should have undefined behavior but I'm not the author of the library.
- pilif 11y ago"Fixing" broken data silently is tremendously bad behaviour in general because you can't possibly know whether the caller knew that they were providing invalid data and whether the caller is going to be happy with your fix. If you expect input parameters in some range and you get values out of that range, then you blow up. You don't silently truncate anything and you certainly don't reduce the entropy of your random number generator by nearly 50%.
- juliangregorian 11y agoA clear example of "worse is better" winning.
- brador 11y agoIf it's documented it's a feature.
- leavinit 11y agohttps://xinrongding.files.wordpress.com/2014/11/bugsintux_012.png https://xinrongding.files.wordpress.com/2014/11/bugsintux_01...
- Natsu 11y agoMaybe they should just make the random functions return '4', documenting that it was chosen by a fair dice roll and is therefore guaranteed to be random.