3 ms·
JS has taken over the world and I wouldn't say that it has a more or less shaky foundation than PHP. See var.
by darkcrag 6y ago
JS has taken over the world and I wouldn't say that it has a more or less shaky foundation than PHP. See var.
- codeflo 6y agoYou do have a point, I’m not the biggest fan of JS either. But notice that var is linted out of every modern JS codebase. Where’s PHP’s equivalent of let/const? Also, I think a huge part of JS’s staying power was that besides its obvious warts, it always had a solid FP foundation as well. JS was one of the first mainstream languages with full closures. That was a powerful tool for building abstractions right from the start, and I don’t think Node.js would have happened without this.
- spdionis 6y agoNot clear why you think php needs let/const like in js.
- ryanianian 6y ago> Where’s PHP’s equivalent of let/const? Olde PHP used to declare global variables for all http get/post params, so "linter rules" basically said no undeclared globals. Of course the linter was a sternly-worded comment in the first <? block. Then we had the $POST array and $GLOBALS which, iirc, are considered bad-practice to interact with directly.
- tored 6y agoEquivalent of let/const for PHP would be manual use of include/require when loading php files, modern code bases rely on an auto loader. There are some legitimate use cases of manually loading a php file, e.g loading the auto loader, but that is usually the exception and not the rule today.
- stephenr 6y ago> Where’s PHP’s equivalent of let/const? Well php has actual constants that are.. constant. So if you’re asking for an equivalent misleadingly named feature, it’d be people declaring properties with an underscore rather than just making them private.