Monday, August 30, 2010

Is Erlang feasible option for Robotic applications?

The answer to this question is not straight forward(yes or no). It involves a lot of study about Erlang constructs, key features and current applications. I am currently working in this area and my work is to figure out some robotic application areas where Erlang certainly can be a good option than imperative programming languages(C, C++, Java).

Here I am writing some points which I observed. comments and suggestions are welcome
1. Erlang being a concurrent language helps in creating multiples processes. The communication model of Erlang is message passing which lets us write concurrent applications without worrying about deadlock, race condition etc.For more see this.

2. On the above property we can make a robotic application where multiple robots are performing a task in co-operative centralized environment. Each robot has its own logic which is controlled by an Erlang server. Some examples are swarm robotics, multiple robots cleaning a room or picking a heavy object.
Let us look at why Erlang will be a good option.
In case of languages which use native threads(C,C++ and Java), there will be a cluttered code having shared memory, loops, process synchronization etc but in Erlang we can use message passing system and other OTP feature to achieve same task in more efficient manner.

3. Erlang's functional nature makes program compact(approx 1/5 times) and readable. This increases productivity also because we can implement a product in less time and push the product before our competitor(less reasonable but true).

4. We can also program "robots with artificial intelligence" using ERESYE which is an additive advantage of Erlang over other languages like C, C++ and Java.

Why process creation time in Erlang is less than Java and C#?

Below are the key points collected by me from stackoverflow, Joe Armstrong's PHD thesis and other web resources.
1. First thing to notice about Erlang is that the word "process" is used because processes do not share data and other resources while threads do share resources and memory(except stack). But still process creation is less expensive in Erlang, how? The answer to this question is that Erlang has the concept of so called "Light weight Process".

2. A newly spawned Erlang process uses 309 words of memory in the non-SMP emulator without HiPE support. Link This includes 233 words for heap and stack memory which can be increased by garbage collector as needed. While in case of Java it varies from 32Kb - 512Kb means at least 100 times more than Erlang.

3. The thread model of Java and C# is OS dependent means that when we create thread in these languages they are mapped onto native threads in someway or the other. But in case of Erlang, processes belong to language not OS, operating system sees only one process which is Erlang Run Time System(ERTS). All process creation, deletion and scheduling is done by ERTS which removes the dependency on underlying OS.

4. The above point is important because it creates a lot of difference between Erlang and other languages. In Java there is certain limit(usually some thousands) on the # threads we can create because of underlying OS but In Erlang we can create millions of threads(I have tested it).

Wednesday, August 4, 2010

How to enable wireless in ubuntu 10.04?

Enabling wireless in windows is quite easy. Here I am suggesting easy way of enabling wireless in ubuntu 10.04(lucid).

Go to system -> administration -> synaptic package manager
then install following packages
bcmwl-kernel-source
b43-fwcutter
bcmwl-modaliases


reboot and everything should work fine. If these packages are already installed then reinstall them.
There may be an exception but this works for me.