Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

You 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.



> 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.


Equivalent 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.


> 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.


Not clear why you think php needs let/const like in js.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: