The full version of this article can now be found here!
One of the most common questions I get asked by my students is “How come you teach Node.js and not PHP in your course?” Telling people “trust me, I work in the industry” simply isn’t enough. So, this is my reason for including Node.js in the course and why if you want to invest in your future as a developer, you should ditch PHP. Although I use these two as an example, in this article, I show you a framework for deciding on what tools, programming languages, frameworks, and libraries you should learn next throughout your developer career.
With your limited time and resource as a developer, you have to make a decision on what to invest your time into to get the greatest return for this investment.
Now, the question you should be asking yourself: What can I invest time and effort into learning that has the greatest net value on my future career as a developer in terms of knowledge, salary, and satisfaction?
This doesn’t mean picking the easiest path. It means picking the tools that allow you to stay relevant and competitive for many years to come while also developing your skills to be a senior developer.
In the Conclusion of this article, you will find all of the technologies I recommend in 2018 if you want to be a web developer using the same analysis done below. So you know, you can skip to the end if you’re impatient. Otherwise, grab a fair trade, organic, made with love, yerba mate tea and let’s go on a nerdy adventure.
We are going to use two types of analysis in this post: Job Prospect Analysis and Technical Analysis. Here we go:
Node.js vs PHP — Job Prospect Analysis
React is the most loved among developers, however, Node.js is the most wanted and second most loved:
Salaries and Opportunities:
Developers using languages listed below the blue line in the chart below, such as Go, Rust, and Clojure are being paid more given how much experience they have. Developers using languages below the blue line like PHP, however, are paid less even given years of experience. The size of the circles in this chart represents how many developers are using that language compared to the others. PHP significantly seems to be rewarding developers less and less with the number of years experience that they have.
On LinkedIn Jobs, you can see the job posting worldwide for Node.js developers far outweighs PHP developers by almost 10,000. This is despite the fact that Node.js is a much younger technology compared to PHP, and the fact that PHP is used heavily with Wordpress which powers 30% of all websites on the internet.
Finally, you can see the average salary for technologies by Region (I didn’t include the Worldwide tab below because PHP didn’t even make it on there):
UPDATE: Since releasing the post, stackoverflow came up with the result of the 2018 survey. The decline in PHP is growing.
PHP popularity is decreasing while the job market and popularity of Node.js is growing. Overall, PHP developers are paid significantly less than other developers and the trend seems to keep widening.
Node.js vs PHP — Technical Analysis
Let’s take a look at pros and cons of each technology.
- Especially suitable for applications that require real time communication between client and server. Tools like socket.io make building things like chat applications really easy. This same features makes Node.js suitable for applications that process data from IoT devices (Internet of Things) and Single Page Applications (SPAs) which are very common now.
- Native serialization and deserialization with JSON which works great with AJAX requests on the web.
- Great for event driven applications that have non blocking Input/Output (I/O is the communication between an information processing system, such as a computer, and the outside world, possibly a human or another information processing systems like Databases)
- The single-threaded event driven system is really fast when handling lots of requests at once from clients.
- There are ever-growing 3rd party libraries and packages accessible through NPM for both client and server-side, as well as command-line tools for web development. Additionally, most of these are hosted on GitHub, where you can report an issue, or you can fork the code yourself to customize it.
- Natively supported on many new APIs and services like AWS Lambda.
- NPM packages mentioned above can bloat your code, can be insecure, and it is hard to find which packages are good since there are so many options (Looking at downloads and GitHub stats is one way to fix this issue).
- Huge number of ways to build servers using Node.js and npm packages. This makes it harder for new developers to pick up.
- Not ideal for servers that are dependent on heavy CPU consuming code (i.e. heavy algorithms like image processing or sorting). Generally, anything that isn’t I/O can be thought of as CPU consuming code. Usually a multi-threaded server environment is a better option than Node.js in this case (Solution: if needed, you can hand CPU intensive parts of your code to a program written in C).
- Node does not utilize all cores of an underlying system or machine. You have to write logic by yourself to use multi core processors. This can be achieved in many ways but it requires a bit of extra work (This becomes a pro when you are able to maximize CPU usage of the system).
Node.js is well suited for applications that have a lot of concurrent connections and each request only needs very few CPU cycles. This makes it extremely ideal for many of the applications currently on the internet like SPAs and real time applications.
Node.js comes with very few dependencies, rules and guidelines, which allow a developer to have the freedom and creativity in developing their applications the way they want to. Developers can select the best architecture, design patterns, modules and features for their project while getting all the benefit from the community through NPM.
- Strong and big community because of its age.
- PHP has a powerful codebase that includes popular platforms for building websites (i.e. WordPress, Joomla, Drupal). CMS (Content Management Systems) such as WordPress, make it easy to deploy a blog or an e-commerce site in a matter of minutes and allow non-developers to customize them easily.
- Easier to set up with non developer tools and preferred for individuals or small companies that don’t need to have knowledge of SSH and Linux servers. Numerous PHP applications (i.e. cPanel) are offered by basic hosting platforms which can be installed in one click.
- PHP7 and HHVM (Supported by facebook) developments have improved on PHP performance… but recently some bad news for HHVM.
- With PHP, heavy server-side rendering and numerous requests to the server to generate and render pages is not be a good option for Single Page Applications.
- Each active client eats up one server process. Not ideal for apps with many client connections.
- Native support for PHP on new APIs and services like AWS Lambda is limited compared to Node.js.
- It follows the classical client-server model where every page request initiates the application, database connection, and HTML rendering. This makes PHP slower as you navigate through a website in comparison to Node.js application that runs permanently and needs only to initialize once. Because of this, Node.js is more suitable for the newer direction that the web is evolving into with HTML5, AJAX and WebSockets.
PHP is simpler to learn with a big community around it. It is a good choice for a standardized solution such as blogs or news sites. It has the power of Wordpress which is the most popular CMS (Content Management System) which allows you to create customizable blogs without too much coding. However, simpler in this case is not a good quality. The easier it is to learn a technology, the easier it is for someone to enter the field and increase the supply pool, and the lower you will have to charge for your services.
In particular, asynchronous and event-based architecture of Node.js makes it a great fit for real time applications such as messaging and collaborative apps in which many requests are happening concurrently and there is a lot of back and forth between the client and the server. Can’t live without Wordpress? Well Node.js has it’s own CMS that is awesome called Keystone.js.
There are always going to be tradeoffs. There is never going to be one technology that you can learn that will solve all problems and will make you immune to job obsolescence. The best we can do is to analyze our options and pick the one that will have best return on investment. Looking at the job prospect analysis and technical analysis above, we can see a clear winner.
I pick Node.js.
Although all technologies are great if used in their own specific way, we live in a world where information is so abundant that we have to limit the amount of topics we can focus on and deeply learn.
In my course, I teach methodologies that are relevant today for a professional career in the field, and also the tools used by some of the biggest companies like Facebook, Netflix, Google and Amazon. If you want to be a full stack web developer in 2018, I recommend you learn:
Node.js + Express.js
and a few others…
You can learn about them more by reading my article on learning to code in 2018 or checking out my online course that takes your from zero experience to having the skillset to get hired as a developer.
What are your thoughts?
UPDATE: discussions around technologies should have opinions from both sides. I recommend you read through the comments. Keep in mind that there are always tradeoffs, and what tools you use in your profession is ultimately up to you. The best we can do is be informed about our choices and not follow blindly. Finally, be willing to consider opinions different than yours.
Thank you for reading this far. If you enjoyed this post, please share, comment, and press that 👏 a few times (up to 50 times). . . Maybe it will help someone.
Follow me on Twitter and subscribe to my blog here if you’re interested in more in-depth and informative write-ups like these in the future! By the way, my full time job is to teach people how to code in the most efficient way possible. You can see my courses at zerotomastery.io/courses