I'm Getting Started with Node.js

Happy 2015!

On many occasions I've decided to get acquainted with a new technology (language, framework, etc.) - SOLR, FW/1, Jenkins, Semantic UI, and a long list of others.  The amount of time I've spent dedicating myself to getting proficient at each of these has varied, and based on the number of years I've spent writing code, I can say that the term "proficient" is pretty subjective.  I've been mostly happy with ColdFusion over the years, but it is apparent to me that cfml is a little like a salmon swimming upstream, and there's a need to expand my horizons in order to remain relevant as a developer (not that I'll be ditching CF or Railo anytime soon).  So I decided to give Node.js a shot.

There are a lot of directions I could go for learning a different technology - Ruby, PHP, .Net, Perl, Python, and so on.  Unlike most of you probably, my full-time job isn't development - I only do this part time for my own personal projects - so I'm not influenced by any particular need within my organization, opportunity for advancement or anything like that.  I chose Node as my next technology simply because I think JavaScript really is awesome, and it's the language of the Internet.  I like the idea of a JavaScript server environment to go with JavaScript front end development and a NoSQL JSON database like Mongo or Couch.  For the first time since I started developing with ColdFusion do I feel like there's a technology that puts all the pieces together in a cohesive manner.  But the great part about Node is that it seems like I'll be able to keep the implementation very lightweight, and more importantly, JavaScript is portable, so the applications I build with Node will be independent of the platform on which it is running.  Awesome.

What is Node.js?

You know that your browser uses JavaScript, right, and that JavaScript uses a document object model to display a web page.  And jQuery, a JavaScript library, is probably the most common way of manipulating that DOM.  However, JavaScript through your browser doesn't have access to your operating system.  By installing Node.js on your system, you're essentially installing JavaScript on your operating system.  It runs within its own enviroment (shell) and it gets access to things like the file system and databases, and it can be used to create a server.  That's important because it allows you to take data such as files or database queries from your machine and use that information in a web page. At first this didn't excite me too much - heck, ColdFusion has done that for years, but this is amazing because it's JS to JS, which means it's all the same code to write and compile - extremely efficient.

Download and Install

So, the first step in the whole process is simply downloading and installing Node from the website Nodejs.org.  Here are a couple videos showing the installation on PC and MBP.  It was all very straightforward.  I accepted all the terms and used all the defaults for installation, and the whole process was less than two minutes.

Getting Acquainted with Node.js

After the installation was complete, I clicked the Node.js shortcut, and I got a terminal (actually it's the Repl). I had no idea what to do next.  It took me back to my childhood when I first booted up an "IBM PC Clone" and got the DOS prompt.

Node.js REPL

Brian Regan

I decided to Google the YouTube* for answers, and I found a really good video explaining the basics of Node.  In the video, what wasn't so apparent to me at first was that the three screens he was showing were Sublime Text (the code editor) on the left, the shell (cmd in Windows, bash in Mac) on the top right (this is NOT the Node Repl), and Chrome browser on the bottom right. He demonstrates what modules are (think .cfm file), the require statement (think cfinclude), some use cases for Node.js, and a little about how Node Package Manager (NPM) works.  In ColdFusion we don't really have anything like NPM unless you're using CommandBox which is fairly new to cfml. Props to Luis and Brad on that! 

The Next Step

I'm really excited to start my first project with Node.js.  In an upcoming post I'll start my first small project - building a static site with Node.js for one of my domains.  It'll be an ongoing experiment, and I'm sure I'll make it harder than it needs to be, but I welcome any input others may have.  This is what learning is all about.  As a side note, I've been trying to do more on the iOS side of things the past year, so I'm going to try Node on both my Windows 7 PC and my MacBook Pro.  I'll point out anything peculiar as I see it.  

* I know.

  1. Mark Drew

    #1 by Mark Drew - January 6, 2015 at 6:47 AM

    Looking good Kris

    the next thing you really want to look at if you are doing web things with node is express. Then you gotta get MEAN! I mean real MEAN! with the Mean stack... http://mean.io
  2. Kris

    #2 by Kris - January 6, 2015 at 7:47 AM

    Thanks Mark! I'm always down for another acronym!
  3. Niall

    #3 by Niall - January 6, 2015 at 2:18 PM

    Nice one Chris! I've been diversifying quite a bit last year especially around Node, IoT, S4TI etc. very exciting stuff. I'm sure you'll get a kick out of it as I did. I've even set up a new blog, hosted using RedHat OpenShift, to document my experiences which I'm hoping to retain momentum throughout this year. Check it out http://blog.thewebagency.net/
(will not be published)
Leave this field empty: