My experience moving from PHP to Node JS in one week

I recently took on a new job where part of my responsibilities includes the development of a web app and collaborating with the API development, and since the API is Node JS I have no other option than to finally give in to learning how it works.

Published Sep 24, 2023
featured image

Let's start with a little background. Just like you probably do, I love to develop things for the web with up to 5 years of experience as a backend developer using PHP, Laravel, Elastic search, Docker(even though it's not a backend technology), and 3 years as a frontend dev, working mainly with Vue as my framework of choice (for the sake of the length of this article I won't get into why I chose Vue over other nice frameworks out there).

I recently took on a new job where part of my responsibilities includes the development of a web app and collaborating with the API development, and since the API is Node JS I have no other option than to finally give in to learning how it works.

So as anybody will do, I went ahead to Udemy and obtained a Node Js course, about 20% into the course I noticed something, apart from the fact that they were basically teaching how the web works, I actually understand everything being taught, then it finally came to me what I have been seeing all over the internet about Node Js, its simply put javascript running server-side, since I know javascript, it all makes sense now.

After that discovery, I stopped the course and decided to learn by trial (btw I wrote an article about how to leave the tutorial hell here) instead, by building a simple API as that is what I will be doing most, from there, actually writing API went pretty smooth with help of documentation and articles on the internet. Then I went ahead trying two frameworks (Express and Fastify) for the same project.

Here are some of the things I noticed in the course of development especially in comparison with where I am coming from.

  • On the language level, Node is quite cleaner than PHP thanks to javascript, though that might be from my preference for javascript over all other programming languages.
  • When it comes to speed, Node JS is faster
  • PHP in my opinion is more powerful so if your project needs a lot of processing in the backend you might want to opt for that
  • On the framework level, with the most popular frameworks available in both languages, Laravel, and Express, Laravel unlike Express is opinionated meaning it encourages you to follow a particular structure while express gives you the freedom to structure your application the way you want to. With that comes some disadvantages too though because if you are not careful things can get really messy so I checked some examples online of how people structure their apps. This repository was especially helpful: https://github.com/santiq/bulletproof-nodejs/

With that I was up and running with node, I know there is still a lot to learn but I believe the basics have been covered.

This is simply evidence or an answer to the popular question "Which language should I learn first?", It doesn't really matter what you begin with as long as its not some really old one, just get started with one you find convenient to learn basic programming principles from which you can then port/move to other languages as you wish.