Tuesday, August 31, 2010

A Weekend With Node.js

Last weekend was the Node Knockout which I talked about my preparation for last week. 48 hours to develop an application in Node.js. My friend Michelle and I set out to learn Node.js more than win the competition. We did a little fiddling before hand but nothing particularly major. Our particular application was a MUD, something we thought would provide an interesting mix of server challenges and general complexity as well as being amusing to us(we first met on the Discworld mud many years ago).

Working with Node.js is a different mindset from most other application work I've done in the last couple of years. The event driven model requires more thought to get state right, particularly as Javascript's notoriously awkward scope becomes so much more prominent when building a full server application rather than just responding to events in the browser. There is power there once you get going though, and we definitely started churning out functionality towards the end of our 48 hours.

By the end of 48 hours we had an evented server that was serving telnet on port 8000, a webserver and Socket connection on 80 and a crossdomain.xml file on 843. All of this in the context of a single Node instance. This was also where the power of something like Node.js really becomes apparent, we had managed to implement a relatively powerful server supporting a wide array of interaction options in a shared space that a number of people could inhabit at once.

(We also managed to create a suitably crazy design with a late ring-in to do some photo-shopping and logo creation.)

The server was able to handle a number of players all talking to each other and interacting in that space without any particular issue or noticeable performance effect. This is an excellent example of how the Node.js style leads to higher performance by default rather than needing to optimize processes for performance later.

Node.js is straight-forward to deploy given that you run the server as part of the application in most cases so it's easy to move it around and put it in convenient places. Unfortunately we didn't have much access server wise as we had a choice between heroku and a locked down joyent instance on solaris which meant we couldn't do some of the more complex ideas we had for separating out our server processes a bit. But it's definitely something to take advantage of for quick apps in the future, it's rare for efficient and easy to deploy to go hand-in-hand.

I've still got an ongoing gripe with the state of naming in Javascript. Everyone seems to be terribly afraid of using too many letters in their method and variable names, probably due to Javascript's history as something that weighed down the client when they had to download the files to their browser. For more complex apps that don't need to be optimized for size people really need to think about improving communicability over code size, it's much much easier to read complete words the describe what something is.

In the end it was fun, I learned a good deal and, as always, I enjoyed the 48 format. I highly recommend 48 hours of something to learn it and doing at the same time as a bunch of other people means there's an active IRC channel full of all the same problems at once.

If you're interested our code from the weekend is on github, as far as I can tell we had written ~1700 lines of code that were part of the final deploy.

13 comments:

James Westgate said...

Yeah, variable naming should never be a problem, if you use scope correctly and a good minifier/compiler like Google Closure

Bus to kuala Lumpur said...

This is a great inspiring Article.I am pretty much pleased with your good Work.You put really very helpful information

Alice Pham said...

well! thanks for nice share! proweb365 provide custom web design at reasonable prices and is always up-front about our affordable web design services. We list our web design prices right on the website, so you can do price comparisons. Our Minneapolis web design firm custom builds professional websites – including eCommerce, Blog, and Mobile Websites - that are easy to self-update and manage, with integrated content management systems (CMS) such as Drupal, Joomla, Magento, and WordPress.

obat herbal denature said...

obat herbal untuk kanker payudara
pengobatan kanker payudara cara herbal
obat kutil kelamin herbal di apotik
cara cepat mengobati kutil di kemaluan
Cara mengobati kutil di kemaluan wanita
cara mengatasi kutil di kemaluan
cara menghilangkan kutil di kemaluan
Cara menghilangkan kutil di daerah kemaluan
cara menghilangkan kutil kelamin pria
BAGAIMANA CARA MENGOBATI KUTIL KELAMIN TANPA KE DOKTER
Obat kutil di sekitar kemaluan dan anus
obat ampuh untuk menghilangkan kutil
obat herbal untuk kutil pada kelamin
reseller produk de nature
obat kutil kelamin yang ampuh
obat alami untuk menyembuhkan kutil kelamin
obat herbal untuk kutil di kemaluan
cara mengobati kutil pada kemaluan
OBAT PENYAKIT GONORE
obat kutil kelamin tradisional
obat kutil kelamin tradisional
herbal penyakit kelamin

Discount promo codes said...

Keep up work hard dude.well done your job.
Godaddy Coupon and Hostpapa coupons .

Nithiya said...

yes.I agree with you. Node.js is a different mindset from most other application.

NodeJS Training | NodeJS Training in chennai |Online NodeJS Training

Amirtha rao said...

Thanks Admin, I just begin my career in sever side web application development for that I complete the Node JS training but I wish to explore more in that, truly your blog provide some useful information and I would like to share your blog in my friends circle so keep sharing.
Regards,
Node JS training in chennai

naveen said...
This comment has been removed by the author.
naveen said...

nise post nice post thanks for sharing confidential couture Coupons

Sathiaja Sarah said...

hi
dear,
When looking to get a website designed or developed, how do you know which web designer to use? There are so many to choose from. Web designers will vary in skill and style and the following article will highlight some points on how to choose the right one.
Take a look at for more: Boston web designer

geethu said...

Excellent post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.
Node JS training in chennai | Node JS training institute in chennai

Rashmi S said...

Head hunters in India
Head hunters in Bangalore
Consultany in Bangalore
Serviced Apartments in Bangalore
SEO Services in Bangalore
SEO Services in India

Brave Technologies said...

Nice Blog, I loved it. Thank you for Sharing. The information you shared is very effective for learners.
enterprise resource planning in chennai | cloud erp solutions in chennai