The best thing about JavaScript is its implementation of functions. It got almost everything right. But, as you should expect with JavaScript, it didn’t get everything right.
It’s been couple of weeks I have started using CoffeeScript (I know it has awesome integration with Ruby on Rails and particularly Node based projects) and I have fallen in love with it.
It’s not like that I don’t like JavaScript but JavaScript is a hard language. I think JavaScript is one of the language that most programmers have used in some ratio and most will say claim they know that language and most of the time it may be kind of wrong assumption.
For those who haven’t used CoffeScript, its a Ruby inspired language (or micro framework) that compiles into JavaScript.
I’ve been using CoffeeScript for couple of projects now. JavaScript source (http://cdn.sailthru.com/horizon/v1.js ) for Horizon, Sailthru‘s behavioral tracking product is generated using CoffeeScript and another one is work in progress, Node.js client for Sailthru API.
Not to forget that CoffeeScript makes using Node more fun!
Here’s dead simple Node server using CoffeeScript:
server = require('http').createServer (request, response) ->
response.writeHead 200, {'Content=Type': 'text/plain'}
response.end 'Hello World'
server.listen 9999
console.log 'Sever running at http://0.0.0.0:9999'
And generated source code:
(function() {
var server;
server = require('http').createServer(function(request, response) {
response.writeHead(200, {
'Content=Type': 'text/plain'
});
return response.end('Hello World');
});
server.listen(9999);
console.log('Sever running at http://0.0.0.0:9999');
}).call(this);
I like the fact that CoffeeScript makes you hard to have global variable because everything is wrapped inside an anonymous function. And of course you can always use global variable in the form of attaching to window object in JavaScript and attaching to exports object for Node systems.
I think I am pretty satisfied with their response and clarity.
Since we are still in the early stage of mobile computing, no one knows what type of regulation and guidelines are to be followed from the context of both users, app developers and Ad Companies. I’m optimistic that all these debates regarding user privacy and the scope of data tracking in the web and smart-phone world will produce some clarity in the future.