3 ms·
People love to hate on PHP then love to love JavaScript. It's bonkers. PHP is clearly better than JavaScript, it's just that we're all forced to use JS.
by deprecative 3y ago
People love to hate on PHP then love to love JavaScript. It's bonkers. PHP is clearly better than JavaScript, it's just that we're all forced to use JS.
- scq 3y agoI really do not understand this take and have to assume people who say this have not deeply used PHP. It has a large variety of bizzare language features that make JavaScript look downright well-designed. Examples off the top of my head: * Lists and dictionaries being the same data type ("array"). This makes it impossible to distinguish between an empty list and an empty dictionary, good luck encoding that JSON. * Arrays are pass-by-value * '123' == '+123' evaluates to true * '0' == '0.000' evaluates to true * `$a = true; $b = false; $c = $a and $b;`, $c evaluates to `true` * Closures requiring you to explicitly list every variable from the parent scope you want to use * References (&$var) have a lot of footguns * array_key_exists and property_exists taking opposite parameter orders * stdlib naming in general being pretty bad, with the stated justification being that strlen() was used as a hash function in early PHP versions, so functions were named to achieve an even distribution: http://news.php.net/php.internals/70691 http://news.php.net/php.internals/70691
- rafark 3y agoAre you serious? https://gist.github.com/shapkarin/b3fbeaca95ef69df177b https://gist.github.com/shapkarin/b3fbeaca95ef69df177b
- blueflow 3y ago* no way to get the errno from fopen (relevant for concurrency things)
- ptx 3y agoHere are two more: * The null-coalescing operator is also an are these even valid identifiers-coalescing operator – here $result is 2: $myvariable['x'] = 1; $result = $myvvvvariiiiableee['x'] ?? 2; * '0e123' == '0e456'
- sph 3y agoGP didn't say PHP is a good language. GP is saying that many hate PHP while praising JS, which is another impressive pile of crap on many fronts: semantics, standard library, ecosystem. All those bad things about PHP you've listed go well with Gary Bernhardt's WTF video about JS's inconsistency. JavaScript is not well-designed however you squint at it, and claims that it's gotten better must come from people that have not used any other language before.
- scq 3y agoI'm familiar with the Wat talk, the flaws in JS are not nearly as egregious. I'm not saying that JS is well-designed, just that PHP is so badly designed that it makes JS look good by comparison.
- CivBase 3y agoI hate both. But to be fair I started hating JS 15 years ago when IE6 support was still important, and I haven't touched PHP in 10 years so it may have improved significantly. I'll still use either if I run into a proper use case for them.