JavaScript has a lot of the same issues as PHP. It doesn’t have some of the same core library issues because it doesn’t have a good core library.
ECMA 6 has had drastic improvements over the past js…
Sure, but it still lacks basic built-in features. For example, why do maps and sets not have sort or filter methods? In Node, why is there no built-in way to connect to a database of any sort? Why can Node.js apps only use a single time zone? Requiring libraries for everything is not ideal as the libraries vary wildly in quality and they can end up either abandoned or containing malware (which has happened several times in the Node ecosystem).
still infinitely better than php
They each have their pros and cons, depending on use case. Node.js does some things better than PHP, but the opposite is true too.
- You can build a whole PHP website without using any third-party libraries, and it’ll work on any web host that supports PHP (literally any good web host that exists today). There’s value in having that level of flexibility.
- You can build a PHP site today and it’ll mostly still be working (maybe with some minor changes) in 5 years, whereas for some of my Node.js sites I have to switch to an older version of Node just to build them. For example https://obviousspoilers.com/ has been practically untouched since 2009.
- The fact that PHP can run multiple apps in the same FPM process means that you can run thousands of sites on a single server without issues. There’s some non-Node solutions to this (like Cloudflare workers) but they’re mostly proprietary at the moment.
- There are more PHP than Node.js jobs, and far more sites use PHP. Wordpress uses PHP and powers over 40% of the web, so that means that at least 40% of all websites use PHP.
Adding a third-party library in PHP is just as easy. The composer.json
file looks very similar to a package.json
.