Last Updated: January 20, 2020
·
2.038K
· caffeinewriter

Falling in Love with Node.js

PHP: A Love/Hate Relationship

I'm a long time PHP user. Well, long time may be an exaggeration, but in my short life so far, it is indeed a long time. However, PHP was seriously lacking features that I constantly found myself in need of. Persistence for one. Sure, there are hacky solutions such as cron jobs, but in the end, PHP is meant to die.

After that, there was my hatred of MySQL statements. I love doing things progmatically, so if I have to write a sentence to a computer, I get a little hot and bothered. "SELECT * FROM Users WHERE Hot='true' AND Bothered='true'", or however it went. Sure, it's simple, but it's always rubbed me the wrong way.

I could go on and on about the things that irk me with PHP, but in all honesty, it's a decent language, I just always end up needing more. That's where Node.js comes in.

Node or Rails?

I suppose that a few people will try and sell me on Rails, but here's the skinny of it. My knowledge of Ruby is sparse at best, and nonexistent at worst. I could, and should, take the time to learn it, but the biggest appeal of Node was that I was already past the worst part of the learning curve, the language itself, which I had absorbed through my self guided journey into HTML, CSS, PHP, and of course, JS. Sure there's plenty of syntax to learn, but it generally keeps in tune with the syntax of the language.

In addition, Rails already foists a base upon you. With Node, it's essentially just the language. Ruby is to Node, as Express/Roots/Geddy is to Rails. Well, to be perfectly honest and fair, Node's somewhat of a hybrid between the two.

Code, Gems and NPM

The wonderful thing about both Node and Rails, is how modular they are. You need a module for websockets? There's a package for that. You need a chess engine? There's a package for that. You want to survive a zombie apocalypse? Well... Maybe not quite yet. What both Node's NPM, and Rails' Gems have in common, is that they'll automatically install dependencies. With PHP, sure there are libraries, but there's no guarantee that they'll play nice with each other. There's no automatic installation of dependencies. Well, there's composer, so I suppose that's unfair to say. I suppose the fact that I prefer NPM and Gem to Composer is sheer bias on my part.

Speedy Node

Node is fantastically fast. It's fastastic. It's able to handle large loads brilliantly, and is extremely scalable. It runs on Google's V8 Engine. There's debate as to what's faster, and honestly, I'm hesitant to speak one way or another on this, but regardless, it's extraordinarily fast as far as web-based programming goes. Or perhaps it's just the norm, and I'm used to PHP being single threaded and slow.

Node has become a passion for me. There are plenty of reasons for me to use Rails, and I probably will in the near(ish) future, but that, my friends, is a story for a different time.