DEV Community

Discussion on: PHP or Node.js: The right technology for your project

Collapse
 
jwhenry3 profile image
Justin Henry

I hate to be the devil's advocate against PHP, but the benefits that php give you have nothing to do with the language or the templatization it was originally intended for. The benefits really come from the server that is compatible with PHP; NGINX/Apache. Outside of the concurrent connection perks of everything running in separate threads, the benefits of PHP start to waver. The C modules and libraries you need to install into the OS make the ecosystem quite rigid. NodeJS benefits from its portability and light-weight nature.

On a side note, PHP does not "interact" with HTML, it simply outputs it into the response as the default form of output. You could output JSON instead and it would be valid, so as the headers were properly set at the top of the file (or in the framework).

The way that PHP outputs HTML could be compared to how NextJS/Gatsby/PUG outputs content.

The interesting conversation is why you pit PHP against NodeJS? NodeJS is the platform in which JS is executed on the server, whereas JS is the language, so it's really a PHP vs JS conversation. Both languages are single-threaded and can be used in a way to give a multi-threaded feel, and the platform in which they stand can become multi-threaded with the right wrappers and/or libraries (or web workers).

The real comparison is how flexible is it, how valuable is it when talking about software engineering in general, what are the benchmarks. Speaking from working in both, I give more value to JS/TS/NodeJS than PHP any day, since work in JS can translate much further than PHP due to its very proprietary syntax and architecture.