Prajwal Tuladhar’s Blog
 
programming, life and some random thoughts

Archive for the 'Programming' Category

Jun 19 2011

Quote from JavaScript – The Good Parts

Published by under JavaScript

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.

~ Chapter 4. Functions, Douglas Crockford’s most read, JavaScript – The Good Parts


Comments Off

Jun 04 2011

CoffeeScript === Awesome

Published by under JavaScript

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.

Go and check the site if you haven’t! http://jashkenas.github.com/coffee-script/

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.


Comments Off

Dec 21 2010

Introducing MongoNormolica

Published by under MongoDB,PHP

MongoNormolica is a MongoDB Master-Slave Replication Library for PHP.

Basically, it manages read slaves and write master connections.

You can select / use slave in number of ways:

  • Radnom Slave Selector
  • Round Robin or in sequential way
  • Most Recently Used Slave

The code is hosted on Github

You can look at the tests folder for implementation for now as, I still need to add more examples.


Comments Off

Jul 29 2010

Node.js talk by Ryan

Published by under JavaScript

Why? Because it’s always interesting to watch Ryan talking about Node.js


Comments Off

Jun 03 2010

Relative performance of Language Runtimes

Published by under Scalability

Pretty interesting graph extracted from Presentation: Scale at Facebook

Relative Performance of Language Runtime

Relative Performance of Language Runtime

I knew PHP has pretty huge performance overhead but boy, just look at Ruby and even Python!

But I am not so sure that Python’s performance cost is as equal to PHP because Python has the ability to generate compiled files also which certainly boost performance.


Comments Off

Next »

RSS Feed
Subscribe by email
Follow me @ Twitter