Saturday, November 30, 2013

Node.js' sweet spot: A 2 years old dev's opinions on PHP, Ruby, Python and Node.js.

I fell in love with programming in 2005 when my sister bought me the book, C++ Programming in easy steps. However, it wasn't until about two (2) years ago that I decided to really learn programming (best decision ever). I still cannot believe I made it this far. Truly, newbie... everyone can code. It just takes persistence.

To be honest, the number of programming languages to chose from was quite overwhelming. C, C++, C#, Java, Ruby, Python, PHP, JavaScript, Objective-C... the list goes on. I settled on scripting languages because I wanted something light weight, and believe it or not at the time my computer was a netbook! Humble beginnings I must say.

However, before I can explain why I think Node.js/JavaScript hits the sweet spot let us take a look at other languages I have picked up on the way.


Disclaimer: Below I try to summarize my opinions on the various languages. My opinions are based on my experiences and your mileage may vary. Prior to digging into programming I had a good understanding of computer systems. Tinkering and tweaking is something I have been doing my whole life.

PHP

The first language on my programmer's journey. I started with PHP, because it is the most popular language on the web. In the beginning I just wanted to be a web developer.

PHP is an easy language to learn. Easy to setup and get going. Runs fairly fast. With good training one can build good PHP programs (Facebook was built with PHP). Yet, I hate PHP.

It is not just the syntax. Even worse is its package management. You cannot have a modern language without good package management tools! Yes, there is Composer, but come on. It feels like a baked on solution.

PHP is a language that has served it's purpose in history. A relic of the foundations of the web. In the fast paced world of technology you either adapt or die. Time to move on.

Ruby

If I were to use one word to describe Ruby it will be "beautiful". Ruby is a lovely language to write in and it has great package management. It is actually the first language I noticed that got this right, out of the box. However, Ruby has its flaws. 

Ruby is slow. Not just on servers, but even during development. Just installing a Ruby gem can take quite a bit of time sometimes. When you get into Test Driven Development that can get  a whole lot worse.

However, my biggest gripe with Ruby is its inadequate support for Windows. I am a Linux fan, but when it comes to development I usually find myself using Photoshop and Illustrator quite a bit, so Linux doesn't cut it. You could argue that Mac OS offers the best of both worlds, but when I started learning to program I was on tight budget constraints, how do you expect me to get a Mac? Macs are cool and all, but for some developers (like moi) Windows is the everyday workhorse.

Python

I always tell my fellow devs, "Python was my first love". When I came to Python I was blown away. The Ruby guys bashed Python, but OMG I loved it! Whenever writing Python code and you felt you were going overboard, you almost always were. It is functional and simplistic power.

I have to say Python devs are also a bunch of really smart people. There are a lot of libraries for almost everything you can dream about. My favorite is Django, one of the best web frameworks ever! It is really for perfectionists with deadlines.

I really have no major issues with Python. Yes, self.. self... self... can be annoying, but I never felt it got in the way of writing great code.

There is one minor hiccup I have with Python. The way Python manages dependencies on a per project bases is ok, but not great. virtualenv or virtualenvwrapper are the tools widely used for this. Having to run you project in a self-contained environment every time IMHO is inappropriate.

Node.js

Node.js is JavaScript for the server. I came to Node just out of curiosity. I was learning JavaScript and Node really pricked my interest. JavaScript is a very quirky language. It took me a while to get the hang of it, but I can say it made me an even better programmer.

Node.js is like bringing a bazooka to a fist fight. They don't stand a chance. F-A-S-T for development and production! Awesome package management with NPM, out of the box. Node has the best package management I have ever used. It does all the heavy lifting without compromising control. Throw in CoffeeScript and even Gandalf will envy you.

Node is now a mature platform in every sense of the word. There are amazing libraries and a lot of really smart people in the ecosystem. The Express web framework is a good example of this. It is one of the best web frameworks I have ever used. It is light weight yet very powerful. Web apps can be simple or complex, without sacrificing control. I confess, I am a control freak. Which programmer isn't? Or? O_O

For someone like me who knew very little JavaScript before coming to Node. It really boosted my developer skill set. Since then, I have moved to favor client side development with tools like AngularJS. Writing APIs with Node comes naturally since JSON is a first-class citizen of JavaScript.

I must say it is a good time to Node. JavaScript is everywhere now. A lot of startups and even big names are using Node. You can even write Android, iOS, Windows Phone and BlackBerry apps via PhoneGap.

For all these reasons and more I think Node strikes the right balance, between programmer productivity and functionality. But Node's killer feature is its package/dependency management.

Hopefully this makes sense to someone. :)


Update: I have updated the article to point out one minor issue I have with Python.