Archive for June, 2012

V8 JavaScript Engine

Posted: June 14, 2012 in Uncategorized

In my last few blog posts I focused on, Event-Driven Programming, JavaScript and Node.JS. Now let’s see actually this works. The JavaScript Engine is an interpreter that executes the JavaScript. These engines are most of the time used in the web browsers; each one has its own engine like for example the IE has its codename “Chakra” and for Chrome the V8. And here comes the topic of this blog post the V8.

The V8 is a very powerful engine developed by Google; it is mainly developed using C++. The main reason I am talking about the V8 is that the Node JS is based on V8. So I tried to understand how the parallelism of the incoming request is done using it. V8 is an open source engine you can work on it and learn more about it from this link. In the coming part I will try to show out how the V8 engine works and how I think this can help the cloud with solving the problem of handling the increasing number of connections.

The V8 is mainly composed of 3 things: Handle, Scope and Context. I won’t take long explaining them, but for more information you can visit this webpage. However I will explain the 3, I won’t go in deep. The first thing is the handle; this is the one responsible for pointing on the objects. The handle is also divided into 2 things, the local handle and the persistent handle. The first one is created when there is a function call, the persistent one is created and deleted when specified, this handle mainly deals with the DOM.

The Scope is the container of the handles according to this website.

For the Context this is the environment that interprets the JavaScript and executes it, one of the important things it offers is that it allows multiple JavaScript code to run in a single instance of the V8 engine.

After Explaining the main components of the V8 so far, let us try to clarify how this works for the Node JS especially it is based on V8. JavaScript running on the server side, there is no DOM to deal with but only with incoming traffic to execute the required functions and return the result. So I imagine is that with each incoming request rather than executing and creating a new context it allows you some of the incoming traffic to share the same context so executing the functions more faster.


Now redefining what Cloud Computing is, I have posted a previous blog post about it before, however the reason that I am rewriting this is I might get a better understanding for this concept or cover it from other point of views. Remember at the beginning of internet era, the internet users might face some problems one of them is the availability of the application or the website they were looking for. Let’s have a small example why this was happening. When X number of users is trying to access the web application, each connection will consume some temporary memory assuming it is around 2 MB, so the server where the website is hosted must have memory more than X*2 or else the server will be down and won’t be able to handle the incoming connection. So the main solution you must do is to increase and to enhance your hardware, regardless what enhancement is done on the software part, you will always need more hardware.

Let’s jump to another part, for the business owners, the large Enterprise companies and some of the medium will have to build their own datacenter and their IT infrastructure. Each time their business grow, the incoming traffic on their applications whether from their clients to the application hosted on their servers or the internal employees accessing the internal system, they will have to buy new hardware resources for enhancing their IT infrastructure. From the last point there are 3 main problems:

  • Availability
  • Scalability (for the memory, storage and processing power they might not find it when needed due to the limited resources they have)
  • Cost

The only solution and the main one is always enhancing the hardware and buying new servers, regardless of the Software updates. So here comes the Cloud Computing role by providing in my opinion one main thing: “Illusion of the infinite of the hardware resources”, which means that the datacenter will have thousands of servers, maybe millions where the applications are hosted. This means that the cloud can provide you with great flexibility with the storage where you can host your storage and processing power for your applications. As it is impossible for all the companies to have their own Cloud, so there is Cloud providers, like Microsoft , Google, Amazon and several others, that deliver you the Cloud Computing as a service.

Let me give you an example explaining the “as a service” meaning. In each factory, you might build your own electric generators for the high consumption of electricity. This cost the factory a lot of money as a capital cost for building it and after that paying in regular way the operation costs needed for only running this generator. Or simply the factory can take the electricity from the country as a service, they pay for the amount of electricity they use and share it with others.

The same goes for the cloud, rather than paying millions of dollars for just building your IT infrastructure, you can take it as a service from the cloud provider where you share the resources with a lot of others companies. This means that you will cut off your it infrastructure capital cost and only runs with the operation costs, depending on the amount of storage used and amount of processing power consumed. More blog posts will be followed about the layer of the cloud computing and how each layer can benefit its users.

Node JS on Windows Azure

Posted: June 8, 2012 in Uncategorized

One of the latest things people have heard about is Node JS, actually when you develop on any cloud platform available, you will certainly hear about it and you may think of using it. So first of all what is Node JS and what can it do more to help you building your application? We all know that JS stands for JavaScript and for the Node, it means the server side. Yes JavaScript on the server side. The Node JS main target is to help you build very high scalable applications over the network… bla bla bla. How is that?

Let’s imagine that you get a number of X of requests on your web application, each one of these requests consume a certain amount of memory, so your hardware resources will only be able to handle the number of memory divided by X, which is somehow limited and costs a lot. (I got this example from this link from ibm developers works). Node JS allows you to execute the coming request with more parallelism using the JavaScript
Event-Driven programming language. In this post we will talk about the same thing but for the server side.

Node is a server-side JS interpreter, it changes all how the server works processing and working with the coming request. Node.JS is a based on V8 JavaScript engine, ultra-fast engine, you can download it, read its documentation and embedded into any of your application from this link.

Now let’s go into the example, first of all after the new features added for Windows Azure for June 2012, we will need to sign in to the portal, create new website and setting its URL and its GIT, you can download and install the Node.JS tools and GIT from these 2 links. Let’s start by opening the Windows Azure PowerShell, and don’t forget to run it as administrator. The coming few instructions will help you building your web application, just write the written commands in your PowerShell Command lines.

After creating the directory, you can now create the windows azure application. But first don’t forget to change directory to the directory created.


If you opened the directory you made and where you created the azure service, you will find the following:

So let’s create the new WebRole for our application.

If you didn’t name the WebRole it will be named webrole1. You can also see the folder created and the files added just by navigating to the browser, you must see the following in the folder named mywebrole.

You can open, modify the server.js by simply entering the following command, you will be able to see the server.js in the notepad as the following picture shows.


Let’s run and see our application result

The result should be like the following picture:

To modify the application or add new pages you can add new JavaScript or modify the server.js already created.

Now let’s upload to our azure accounts, supposing you have download the Git, created a new website and set the Git Publishing credentials. To do so, after creating a website application on the Windows Azure Portal you will find a link called set Git Publishing on the right most of the window, after clicking on this link:

Now depending on what you have chosen during the installation, I mean I have chosen the Git Bash, you may have gave it the permission so you can access it through the PowerShell. In both ways, you will choose the same commands.

Make sure you are in the right directory and start initializing GIT by the following commands

Now continue and enter the following command to make the connection and the deployment of the application to the portal.

You can get this URL from your portal from:

The last command line is

Now if you simply go to the link of your application you will find the hello world we create J



Posted: June 8, 2012 in Uncategorized

JavaScript is now a very widely used programming language. Most of the time it is used on the web browser, for the purpose to add interactions on the websites. So let’s try to understand what JavaScript is and how it works? As I mention before this programming language is mainly designed for the web browsers, all the browser has to include an interpreter to execute the JavaScript code.

JavaScript is a scripting language, not an OOP language however it is an event-driven programming, it handles the events done, and for more information on the Event-Driven Programming you can read my post. For JavaScript, it deals with the pages of the website as Objects. Each object can include other and so on. In other and clearer words, each window includes the document for the webpage where it might contain images, form or multiple forms. In each form there are multiple fields, textboxes and so on. We call the previous the previous example DOM, Document Object Model.

Let me redefine DOM again, it is a framework for JavaScript that give it the capability to deal with each object in the document, and react to the events done on it without the need to load a new page or even reloading the page. I have made a small example using JavaScript in a web application:





function changeproperty() {

document.getElementById(“txt”).innerHTML = “AIE”;





id=”frm” runat=”server”>


ID=”txt” runat=”server” Text=”this my text that will be converted”></asp:Label>

name=”btxt” onclick=”changeproperty()”> Click Me!!</button>






What this code really does is changing the text of the label named txt to AIE on the click of the button named btxt.

And the result should be

To mention JavaScript was first developed by Netscape, and then was implemented in all the browsers. The point, after that each company started developed its own, you might find programming language called Jscript, Ecmascript, they are different implementation for JavaScript before being standardized by w3c. For more information I recommend you visit this website. If you are really interested to learn JavaScript I do recommend this website.


Event-Driven Programming

Posted: June 8, 2012 in Uncategorized

As I am a developer I love to explore all the available things even if I won’t use it. Practically I am most of my time using the C#, C++ programming language. Most of the Programming Languages I knew or even I studied were all about object oriented programming where the classes and the objects were all the most important things. However after diving into the Cloud Computing and developing on multiple platform, I found several new things like the new concept of programming Node JS, I will blog about it later. One of them was the Event-Driven programming. Event-Driven programming is a programming concept based on events, can be from human interaction with the application or any other interactions. Like for those who know about the assembly language or embedded systems, the event driven programming is like the interrupts. Another important thing you might think of the Event-Driven programming is how the application can handle a lot of events from a single user and process them all without making him feel that it is costing any processing time. In other words the event-driven programming is a way to handle continuous inputs or events done on your application.

Let me give you a small example of something you might have been used. When you browse to any web application, go to the menu and press a certain button, you might find that you get the response very fast without even feeling it is taking any time to send the request, get a response or even without changing the page you are in. What really happens is when you click this button, you trigger an event and the web application will send the request for this certain function and gets back to you the response in one of the available formats like JSON, XML and so on…

For the Event-Driven programming, you can use it with any programming languages. Let’s have few examples with some programming language for the .Net developers, let’s assume that your application has a button in its UI so when the user click on it, it triggers a new event.


Here another example for the events that you might think of is when the user start entering a text in the text block. For the ASP.NET developers you can find the OnTextChanged=”X” and name the function as you wish and you can interact with what the user is entering while he is doing so. I will follow with more blog posts about this topic and will focus later on, on the server side, the Cloud.