by WA · 9y ago · 0 comments
How so? Because when I put a PHP script on a server with "<?php echo 'Hello world' . date('Y' time()); ?>" that is a one-liner and I'm sure it'll work for the next 20 years.
With nodejs, I have to implement the whole webserver and then my web app is also a server, even if it's "only" 20 lines of code and I need other tools to make sure that this server never crashes or automatically reboots and all that stuff.
Imho, the main benefit of PHP is: You can write a script today and because the language is mature, it doesn't change all the time and you can be quite confident that it'll keep running for another decade.
Web hostings have abstracted this for you. In reality, you need to install Apache or Nginx first. PHP does have a built-in server but its for testing only not production.
Nodejs is both a server and a webapp. You just need to install nodejs at bare minimum to run a "hello world".
Try installing nodejs and php on DO to see what I mean.
With regards to nodejs overtaking PHP, various stats from various sources back this up.
> it doesn't change all the time and you can be quite confident that it'll keep running for another decade.
Now thats just false. The switch to PHP7 from PHP5 alone has many BC breaks. Latest Drupal is a rewrite. Laravel LTS dont last "a decade". Code breaks all the the time in PHP land. The only thing that dont change in PHP world is WordPress.....
Your example doesn't account for any complexity. All it seems to say is "You don't have to think about architecture or platform, you can pump out thoughtless abandonware with ease."
Also, pick the right tool for the right job. Who writes code these days that silently sit still for a decade? Hardly anyone. And even if you do, I don't think Python or Node will suddenly stop working (as you're implying).
With the "https everywhere" movement, the same is practically true for node. You will likely be configuring some outside proxy/webserver.