DEV Community

Discussion on: What made you switch your main programming language?

Collapse
 
developius profile image
Finnian Anderson

I made the switch from PHP to Node.js recently due to a few reasons.

When I started with PHP it felt amazing, I could code on my server and the changes would be applied instantly (ikr, really great idea, editing prod code). I owe my love of coding to PHP because the barrier to entry is so low and it really got me hooked. I wrote my first small-scale app in PHP and I had no idea what a framework was back then, so I wrote classes for the database 'entities' (now we call them models). The app became a pain to maintain and I had zero test coverage.

It was around this time that someone introduced me to Node.js. I thought it was a bit of a toy really, for the cool kids. I kept going with PHP for a bit longer and then out of the blue I discovered Mongoose (an ORM for Node & MongoDB). Wow. That was cool. I could define all these methods and validations and all sorts of funky things on models and I thought this was super awesome. No dirty data in my database! The idea of an ORM was something I had never come across before and so I was absolutely hooked on it. Remember that PHP app I was developing? I threw it out and rebuilt it with Node and Mongoose. I'm still developing it now and I've learnt a lot along the way about CI/CD, testing, all that kind of stuff. And I love it.

Recently though, I've been doing some Rails for a client project. It was really comforting to come to an MVC-based framework because it meant I had a good understanding of how it all fitted together. Then it was just a matter of learning Ruby (basically, just write plain English). I've been blown away by how well thought-out Rails is and things like rspec, capybara etc are things I've come to love. I'm still very much a novice on the Rails front, but I know the basics.

When I come back to my Node app, I really miss having a well-designed test suite (mocha is okay, but it pales into comparison compared to rspec). What I do not miss though, is migrations. Urgh. Rails does an excellent job of dealing with that for you, but I still don't like having to restructure the DB now and then. It's not fair to blame that on Rails though, that's just how structured/relational databases work. Another thing I love about Rails is being able to do very advanced model associations like HABTM, which with mongoose is a pain to implement. All those .populate()s! I'm not going to go on a callback rant because, well, I'd probably fail silently.

So, I'm now at the point where I know Express & Mongoose inside out and back to front, but Rails is coming up fast behind them. I'm not entirely sure what to focus more time on, getting Rails up to speed or bashing out more JS. Rails is far more adopted, but I've got this feeling that Node is going to start to become more widespread, even if it's got some serious design problems to overcome first (yeah I'm talking about you, promises/callbacks/ORMs).

Another lang on my radar is Go, so maybe I'll give that a serious try at some point.