Friday, November 22, 2013

how i learnt to stop worrying and love the Javascript

It's been an eventful week for me with lots of new things for me to try on. But the centerpiece for me remains into trying out various things using Javascript based programming application stack.
Even after doing javascript since 2005, until recently I never had the chance to dig deep into it. Also, when I first came to know about node.js in 2010, it was a pretty nascent technology in those days and was not developer friendly. However, a lot has changed since then and now this technology app stack is not only matured, but is also mainstream. Considering the recent interviews that I undertook in last month, apart from rails skills, people also asked if I was comfortable with node.js, which might not be an indicator for the rails community, but is nevertheless a repetitive occurrence for me.
Currently the app stack stands as follows

Client--(ember/knockout/angular)----json data----Backbonejs(nodejs)---Json data---Mongodb(database)

This is essentially a complete app stack built on javascript (with DSLs thrown in for convenience - such as json).

Coming to backbone, it is quite similar to sinatra and is considerably easier when compared with native nodejs and many concepts are used similar to what has been done in the sinatra framework.

var express = require('express');
var util = require('util');
....  //Other libraries in use here
var app = express();

app.set('views', path.join(__dirname, 'views')); // set the views here
app.set('view engine', 'jade');  // using jade view engine

  //let the app use various activities

//routing stuff... that can also be delegated to separate files
app.get('/a/url/path', function(req, res){

app.listen(8080); // port to listen upon

Using mongodb with this is also quite easy as many choices are present when it comes to selection of a data mapper. I used the mongoose for this, but the only caveat is that we have to explicitly define its metadata. For user authentication, I learnt and used passportjs, which is  quite lightweight and concise in using .
In the client side, there are a lot of Model, View + based  javascript frameworks out of which I am learning angular and ember frameworks. Currently I am not biased towards/against any framework out there and will definitely post my experiences..

No comments: