Node.js or PHP for a large-scale web platform?
Here's what we've been up to recently.
Both PHP (with Laravel) and Node.js (with NestJS) will do the job, but there are a few things we took into account that helped us make our decision:
- PHP is great, especially with the latest releases, it offers great performance and a lot of improvements, but still, Node.js shows better performance thanks to the async approach
- NestJS enforces good DDD architecture and separation of concerns, so one can invite an Angular Front-End developer to work on the back end and he/she would manage with ease
- Node.js is better when it comes to building a JSON API — it is not messing up with HTML (separation of concerns), while with PHP you may have the temptation to serve HTML right from the monolith
- Node.js and especially the NestJS communities feel more conversant. In the PHP world, it takes more time to filter out the noise, there is a lot of information for every potential problem you have in PHP, but most of the solutions are far from the best
- npm/yarn have a large pool of dependencies and they require more wise picking and double-checking when it comes to installing yet another dependency in the project. Personally, I don’t think the composer world is much different. you always have to think twice and verify when you invite someone else to contribute to the code inside a project
- TypeScript is way better than PHP’s native types of “warning” support. Of course, it comes with a learning curve for people who have never used a strongly typed language and it has drawbacks when you want to use some npm dependency that doesn’t have TypeScript support, but the truth is that almost all of the popular packages already have it
In the end, based on all of the above, we chose Node.js and so far everything looks promising in terms of performance, development speed, unit testing. We will be happy to share another update after a couple of months, where we will cover the biggest challenges we have faced and essentially provide an answer to the question “Would it be better if we were doing this with PHP?”