My First Impressions of node.js

Over the holiday season, I thought it might be fun to try the node.js on azure walkthrough here. Up until recently I never even heard of node.js, but lately it’s been all the rage so I figure I owe it to myself (and my customers) to be up to date with it. So here we go. First off, what is node.js? The quick answer to that is its server-side JavaScript. With all the JQuery, and Ajax going on, it seems like the next logical step is to push JavaScript onto the server and stick with one language. If you’re feeling a little squeamish after reading that, then you’re not alone. There are so many servers out there, why do you need another one?

Well, one of the cool things about node.js is that it is the smallest looking server I’ve basically ever worked with. Smaller then Apache. In a few lines of code you have your entire webserver there ready to accept requests. That part is nice and powerful. If you want a longer explanation  of node.js itself there are some here, and here. Seriously, read those explanations. 

Granted, I may not have really given it a good honest try, but i  can already tell I don't really like it. I expected at first i would just be able to write an HTML and javascript/Ajax page and then just ask node to host it, adding in server side code to go with the Ajax. But noooo, apparently you need to design the pages in something called Jade, and then have something called Express translate the pages. Now it reminds me of Ruby or Grails. I'm sure there are other interpreters then Jade/Express, but I have a feeling it's going to be another thing i have to learn anyway. I guess that's my biggest gripe so far.

Troubleshooting is the other issue I have with node.js. As i was going through the examples from the node on azure walkthrough, and on the node.js website, I would occasionally make some silly mistake. Maybe i didn't close a paren, or mixed some capitalization, but in either case the only error I would get is a page telling me there was a 500 error. I had no idea where the problem was. The js? My jade/express? Was a file in the wrong folder? No idea, i just had to comment things out until things worked again and then slowly get the new changes working. Hugely annoying. Some sort of message would be nice. I realize the language isn't compiled, but still.

With those things, I have a hard time finding a good reason to use node.js. Especially with the learning curve. I'll find a reason though! Sometimes when you have a hammer like this, you need to find a nail. :)

Part of the reason I wanted to learn some node.js was because Microsoft made it easy to put onto Azure, which is handy and a load of fun! All of the tooling to get settings, create the necessary files, and publish your project is all done through Powershell. Notepad and the command line is all you need. Like I mentioned already though, I have mixed emotions doing it this way.

The benefit to having node.js on Azure, is its lightweight, and you'll probably be able to do more with a smaller VM size - saving you some money. Also it was actually pretty simple to get a full node.js solution up and running on Azure. I don't know if it's going to be much easier to get it going on a stand alone server. Plus once your traffic grows, and you need more power, all you'll need to do is either increase the size of your instance, or increase the amount of instances. No additional configuration will be needed. That's going to be a whole lot nicer then your typical on premise server and you have to migrate it onto a bigger server later.

Don't let my lackluster review of node.js prevent you from trying it out yourself. Its a popular framework right now and it may solve a problem you have. In fact if it IS solving a problem you have, let me know in the comments, I'd be excited to hear about it.

Comments

  • Anonymous
    January 13, 2012
    Just wanted to let you know that none of your links in this article work. They all send me to Windows Live control panel.
  • Anonymous
    January 14, 2012
    Thanks punkcoder. You were correct. +1 internets for you. Fixed.
  • Anonymous
    January 14, 2012
    I would suggest checking out now.js on node.js. I think it is quite impressive.
  • Anonymous
    January 14, 2012
    CaseyYou can definitely host static HTML content through plugging in a module. The common convention being putting it in a public folder. Express actually comes with a scaffolding tool that does this for you.If you do "npm install express -g" (-g = global) it will put the scaffolding tool in your path. You can also install express locally using "npm install express". In that case to run the express tool, run ./node_modules/.bin/express.When your run the scaffold it will generate a new app.js. Open it up and you'll see where it sets up static files to be served.If you look at many of the express samples you will see they also use static file serving.
  • Anonymous
    January 16, 2012
    So true! node.js is a worthless technology made by geeks
  • Anonymous
    August 28, 2013
    I've done .Net consulting in NYC media market for years and I really disagree with your assessment. IMHO, The reason you would use node.js is because it is non blocking event driven language, which gives it a huge advantage when doing IO operations that take a lot longer otherwise. I am not too keen on the syntax as well, however, it is something you can learn fairly quickly since we all have done some javascript in the past."apparently you need to design the pages in something called Jade, and then have something called Express translate the pages."  You really need a framework in any language you pick pretty much short of writing static html hardcoded to a page. For an example, in order to run a view (in MVC world) in .NET, you need to learn Razor then need .Net Framework that will interprets the page into html for you.Jade is a single of many flavors you can use, personally, I prefer EJS, or even deal directly with Angular which makes things more interesting.I think that MEAN stack (MongoDB, Express, Angular and Node.js) is optimal to handle large IO or Big Data problems.I'd stay away from  node.js if you have a CPU intensive operations, in such, I'd go with C or maybe Go (if you don't mind to learn yet anything syntax)
  • Anonymous
    January 04, 2014
    The comment has been removed
  • Anonymous
    January 23, 2014
    Just for the record. If you don't use express you can basically do your webpages however you like.var fileserver = require('fs');var url = require("url");var http = require("http");var server = http.createServer(function handler(request, result) {   var pathname = url.parse(request.url).pathname;   var full_path = __dirname + pathname;   fileserver.readFile(full_path);}).listen(3000);