To kick-start this blog off I’m going to explain my recent escapades into NodeJs.

You may also be interested in our follow up post Why I’m diving into NodeJs Part 2.

NodeJs vs PHP

Just kidding, this isn’t a language fight post.

As it stands I’m a PHP Developer through and through. PHP is what it is, and its served me well so far, and for now I don’t see that changing anytime soon. With frameworks like Laravel and Symfony, and CMS goliaths like WordPress and Drupal PHP isn’t going anywhere.

The web is filled to the brim with NodeJs vs PHP posts right now, this isn’t one of those posts but I can see why they are being written.

Node is the new kid on the block and on the face of it is in direct competition with the PHP ecosystem. I don’t see it quite like that but the comparisons are easily made.

PHP is a well structured web specific language, which is what it’s for. JS guys will be claiming the benefits of NodeJs are “code reuse”, “performance”, “async”, etc. But with PHP7 now released the performance argument isn’t as decisive as it once was (though NodeJs is still the leader).

The way i see NodeJs being a game changer are for some things people seem to be missing.

Development Mindset

While switching from PHP back-end to HTML/JS front end doesn’t seem like a big thing when developing, it can just make you pause for a second, sometimes you can (especially with syntax similarities like PHP and Javascript have) just forget to use + instead of . when concatenating strings for JS (this may be a moot point with ES6 template literals).

These small, oops, darn it moments add up over a week of hardcore coding.

Async

Async, async, and more async. The ability to run intensive, independent tasks AT THE SAME TIME is becoming more and more important with the users need to do things fast and provide a faster web.

Code Reuse

Hang on? didn’t I say this wasn’t a core reason for NodeJs?

Well yes I did, but not in the sense so much or sharing between the server and browser, while that aspect has its benefits, the reuse I’m referring to is tasks, and testing.

Say for example you’re working on an application, it will have an api, admin area, and front end. Great nothing unusual there. Now you need to test it all.

In a PHP project you would use something like PHPUnit, or Codeception.

Hang on? You still have a front end! so lets test our JS code as well, you may use something like Chai to test functions.

If your just using JS (like in NodeJs) you can use 1 testing framework.

Now none believers will say you can use task runners like gulp, grunt to automate all tests in one go. Yes you can, but that’s another step, another few lines of code you can do without.

 

In the next post I’m going to go a little deeper into this and explain some more reasoning, and soon i’ll be showing off a little NodeJs module (when its ready).