There has been a lot of blogs written about how php is bad or node is bad, but most of them are missing a lot of context.
Most of the time it seems like a marketing campaign for adoption or circle jerking to boost their own language/framework.
I have worked in both php and node environment’s and I just want make more people aware of when you should use what.
I will give real points not something written by someone who just did the hello world tutorial and claims to be an expert.
PHP
PHP is in a very establish and mature language people have heard about for decades. This also means that a lot of solutions
have been developed in this space that are ready to use.
Some good features of PHP
- PHP gives you direct response once you hit the same button. No other language/framework give you this. This speeds up the feedback loop. No starting servers or other things
- Establish library of packages in composer so you can find solutions for what you need
- Has many establish open source projects that you can use and focus on your business (wordpress, drupal, etc.)
- Easy to learn, do follow best practices that software engineers should know(classes, interfaces, etc.)
- Very little ramp up time to setup the system to start coding
- Lots of tutorials to almost anything you need
- Still being upgraded and maintained
- Huge community
- can deploy to almost any VPS server for clients without much hassle
- file sizes are very small
Some bad features of PHP
- Since the community is so establish, people in third world countries are very familiar with php and they will compete with you for projects. This drives the price for PHP development and developers down.
- Wordpress developers give php developers a bad name
- Wordpress developers not being as knowledgable in software development practice
- Wages are a lot lower than other languages
- not setup in a way to support scaling
- not designed to handle asynchronous. Need work arounds
- Not designed for single page applications
- Stigma by other people for being simplistic, easy, non developer work
When to use PHP
I think if you are doing work for clients that need establish software solutions, I would go for PHP ever time.
From a business point of view especially startups, PHP provides a lot of products off the shelf for you to focus more on
your business instead of trying to reinvent the wheel. I think from a developer point of view, you should try to move away
from PHP due to the depreciated salaries.
The most common argument you hear from other bloggers is that PHP is slow. But the real question you should as is
how much speed do you actually need on your site?
Does a CRM need to react to millions of request per second?
Does a CMS need to react to millions of request per second(if it does, you can always cache it in redis)?
Does a forum care about react to millions of request per second?
Does a Ecommerce solution need react to millions of request per second(maybe, but again you can cache it)?
Does a Blog need to react to millions of request per second?
Does a time tracking software need react to millions of request second?
Problems that need to be fast:
- API servers (multiple devices hitting it like mobile, desktop, IoT)
- front facing website
- ad servers
- real time services
Here’s a few example of solutions you should use PHP for:
- blogs (I would use wordpress. Why try to reinvent the wheel to do the same thing?)
- ecommerce (I would personally go shopify for small shop, it has better UX and more stuff done for you. But you could use magento, opencart and other establish systems)
- creating an ad server (revive-adserver)
- forum site (phpbb)
- time tracking software (lots of time tracking solutions)
- ERP solution (inoERP)
- CMS (drupal)
- CRM (sugarcrm, suitecrm)
- helpdesk solution
Node
Node has come out in the past few years and has exploded in popularity. Node selling point is that it’s single thread execution,
speed, and one language for the system. It basically became what ruby on rails was years ago.
Some good features of Node
- it has a very good package manager called npm
- it has very simple to use and learn frameworks
- it seperates frontend from backend code which is a new paradigm
- it can handle 250,000 request per second with 1 server running
- lots of tooling is created
- if you know front end javascript, you can pick up node
- supports asynchronous request
- designed to help single page application
- lots of people haven’t adapted it so salary are high still
- very good for CRUD like solutions
Some bad features of Node
- asynchronous request can create callback hell making the code less readable
- lots javascript flaws start to show when you code in node which can make code very messy if you have a bad developer
- not a lot of solutions created for you
- huge file sizes fro project due to libraries (I’ve had 250MB)
- isn’t as supported as PHP for VPS type servers which most clients use
- not as easy to setup. Need to DIY a lot more
When to use Node
I think you should use Node if you need the speed. Some good examples are:
- system needs to be very custom it
- JSON management(CRUD)
- API server
- microservice architecture
Overall, I feel it depends whos asking the question. If your developer, Node is more marketable than PHP. If your business
and need to get stuff done use PHP. If you need a very custom solution and have the people to do it use Node. Even tough I
said PHP wasn’t design for certain features, you can always work around it.