Monday, October 10, 2011

a bit of fun

Breaks are good.

I've been waiting on a few fixes for Jawaya from the intrepid Ryan, who has real paying work to do as well, so in the meantime I've taken a step back from Jawaya until after this post.

Note: I'm at best an intermediate programmer; and this post is targeted toward beginners and intermediates. If you're a code jockey, you may find yourself guffawing out loud as I say things like "tests? we don't need no stinkin tests!".

In the meantime, I've been playing with some cool technology, and having some fun with it. Node.js is a lot of fun to work with; it's an http server written in Javascript, which has become fast enough.

My goal is this: to build a useful app entirely in Javascript, from the database to web server to framework to browser stuff. Why? Well, I know JS, so I don't have to learn the language, just the tools.

The nicest thing is that you don't have to ask your brain to think differently each time you switch from browser to server to database. That said, I'm using a templating system that isn't JS, but it eases working with HTML, with which I'm already, of course, comfortable, but the syntax is really clean.

So here's the toolbox:

  • web server: Node.js
  • real-time goodness: sockets.io (for chat, streaming, etc)
  • model, view, control framework: Express.js
  • HTML templating: Jade. Clean, simple, outputs HTML. Can incorporate JS.
  • CSS Templating: Stylus. Really clean, much cleaner than CSS and outputs to it. 
  • database: MongoDB. NoSQL document database, stores in BSON/JSON, which of course is Javascript-based object format.
  • database ORM: Mongoose. Basically makes it simple to work with Mongo, which is already simple, but cuts down on the amount of overhead. If you like dot notation, like user.name='charlie'; user.save(); then you're going to love Mongo and Mongoose. Note: mongoose documentation ain't great, so make sure you study the Mongo docs. 

So on top of Node, I installed NPM, which is something like node package manager for installing and managing node add-ons called modules.

For instance, installing express is simple: npm install express.

So I installed the Express.js framework, which is a lightweight MVC framework. The tutorials were easy enough to get up and running quickly. It's much like Rails, but less terse, and given I know Javascript but not Ruby, it's easy for me to pick up.

Then I installed Jade & Stylus, and then mongo and mongoose. I was able to test each of those pretty quickly, and had minor problems I was able to get around.

The real fun came in when I installed sockets.io, which instantly gives you real-time functionality. Imagine killer-fast multi-player gaming, where you have to send, receive, and render real-time data from multiple sources. Fun stuff.

Note I'm not offering any code samples--I don't have the time today and this blog isn't really designed for that.

So what's the point of blogging it? Well, I think I've seen the future, and the future is Javascript. Which sounds crazy--a lot of people hate Javascript. Yes, but everybody knows it, and when all the components of your apps are in JS or jQuery, from server to mobile, suddenly you've enabled everyone to build robust killer realtime apps.

And somebody ported node to the iPhone, which enables so, so much. I can't even begin to get into the possibilities here, but I guarantee you there will be a huge amount of investment in the mobile node.js space. Huge.

Breaks are nice. But break's over--back at it.

No comments:

Post a Comment