Friday, December 25, 2009

Open Source in Developing Countries - I

The "Free Software Movement" that Richard Stallman started in 1983 was brought a big leap forward by "Linus Torvalds" in 1991 with the invention of Linux kernal. Other open source evangelists like Eric S. Raymond and Bruce Perens have major contributions to the open source movement. Have a look at the history of free and open source software in wikipedia. (There are philosophical differences between Free Software and Open Source Software, discussion of which is not the intention of this writing.)

Open source has emerged as viable alternative to the expensive proprietary software. From operating system to user application, from eye candy multimedia applications to serious research projects, from embedded system to large server, from desktop to web application there exist suitable software applications to serve the purposes. In the contemporary world, corporations are constantly fighting for lowering operating costs. Many have already opted for Open Source software stack.

Software is a tangible staff. It is easy to copy and run in other machines. Most developing countries don't have any strict laws to protect the intellectual property (IP). Even if there exist some laws, they are very rarely enforced. Many societies also don't consider it bad to pirate (aka steal) software and don't discourage this practice.

But the world is changing. Many developing countries are immensely contributing  to the advancement of the IT industry. The software development was once mostly centered in the US. But the landscape is rapidly changing. India and China have emerged as software development power houses. Other developing countries including Bangladesh are also continuously progressing in this area. These countries produce world class software engineers who are frequently creating sophisticated software applications. Companies are spending money to build software and they will definitely want return from their investment. If their products are pirated, they can't be happy. Therefore, pressure is mounting to derive laws for protecting the intellectual properties of their own software in many countries.

Globalization has also huge impact on pursuing laws to protect IP. Under the hood of Globalization, the dispersed national economies worldwide are integrated into a interdependent global economy. The multinational corporations are very much concerned over how their IPs are protected in those countries where no IP protection laws exist. These companies often have immense power on the political system of many developing countries. They together with their respective home countries will influence or pressurize to derive new laws for IP protection.

So the days are not very far when most countries on the Earth will have more or less homogeneous IP protection laws. The citizen would be obliged to pay for using each commercial software. This will obviously be a huge burden for the society which is accustomed to pirate software. The moral setup will be more difficult. If someone is comfortable with software piracy, how to resist himself from it.

It is now necessary to realize that there are potential alternatives to usual proprietary software. There are replaceable open source software for almost every commercial applications. In the next post, I will explain how to change the mind set and get accustomed to open source software.


Thursday, December 24, 2009

3D effects in Avatar are mind-blowing

Just watched James Cameron's epic film "Avatar". The 3-D visualization effects are mind-blowing. Otherwise, the story is not much different from usual Hollywood movies. A brilliant guy (mostly a white man) from so called civilized world arrives in an unfamiliar and uncivilized world (in this case in a moon called Pandora), learns all tricks to survive in this very hostile society in few days and becomes its leader, and finally, leads the society into victory from the aggression of a civilized society (in this case, which he is originated from).

Anyway, the film is worth watching, if possible in 3-D capable theater. James Cameron has produced yet another sci-fi masterpiece.

Wednesday, December 23, 2009

Sun Microsystems: Java EE 6 and GlassFish Enterprise Server v3 Virtual Conference

A comprehensive set of Webinars from the virtual conference held on December 15 is made available. Great source if you want to start learning Java EE 6 and Glassfish v3, first reference implementation of Java EE 6 standards.

Sun Microsystems: Java EE 6 and GlassFish Enterprise Server v3 Virtual Conference

Monday, December 21, 2009

Value Type vs. Reference Type + Boxing vs. Unboxing


This post is part of my ongoing effort to familiarize the readers with the commonalities & variabilities of C++/Java/C# programming languages. A tentative outline of this series can be found at Contents.

I was initially thinking to discuss the compound types today, but have decided to briefly explain two important concepts that will be helpful to understand the building blocks and inner workings of compound types. Let's start with the first concept - value type vs. reference type.

Value Type: Variable of value type directly contains value. If you assign a variable of a value type to another, the data will be copied to the target variable. If you pass a variable by value to a method, changes made to the argument will not be changed since a copy of it will be passed to the function. All basic types except string (but it's also copied) discussed earlier are value types.

int a = 10;
int
 b = 20;

b = a; // value of a copied to b
b++; //increment b by 1

printf(" a = %d,\n b = %d", a,b);

Output:

a = 10;
b = 11;

Reference Type: Objects of this type hold a marker to the real data values. So assigning a variable of this type, points to the same data value. This type is more common in object oriented programming.

class A
{

private
:
    int
 m_value = 10;

public
:
   /* Return the value */

   int
 GetValue()
   {

      return
 m_value;
   }

   /* Set a new value */

   void
 SetValue(int value)
   {

      m_value = value;
   }
}


A* a = new A();
A* b = a; // b points to a

b->SetValue(11);

printf(" a = %d\n b = %d", a->GetValue(), b->GetValue);

delete
 a; // delete object, only once

Output:

a = 11;
b = 11;


Value types are stored on the stack and Reference types are stored on the managed heap.

Another important concept very important in managed environment like Java and C# is Boxing and Unboxing. Each value type in Java and C# has a corresponding reference type. Boxing/Unboxing deals with the conversion of a value type to its corresponding reference type and vice versa.

Boxing:
Boxing is the process of converting a value type (e.g. primitive type) to a reference type. Java has reference types for its primitive value types. Conversion from value type of the corresponding reference type is automatic. C# primitive types are converted to the corresponding .Net types as listed in Basic/Primitive Type post.

Unboxing:Unboxing is, as expected, opposite to boxing. It converts a reference type to the corresponding value type. In both C# and Java, the conversion is implicit, therefore, doesn't need explicit casting.

Java
/* Boxing Example */

int
 i = 10;

Object obj = (Object) i; //explicit boxing

Integer intObj = (Integer) i; // explicit boxing

Object obj2 = i; //implicit boxing

Integer intObj2 = i; //implicit boxing


/* Unboxing Example */


int
 i = 10;
Object obj = i; //boxing

/* Following will not compile. 
No explicit conversion from object to int 
*/
/*int j = (int) obj;*/


Integer intObj2 = i; //boxing
j = intObj2.intValue(); //unboxing
j = intObj2; //auto unboxing
C#
/* Boxing Example */

int
 i = 10;

object
 obj = (object) i; //explicit boxing

Int32 intObj = (Int32) i; // explicit boxing

object
 obj2 = i; //implicit boxing

Int32 intObj2 = i; //implicit boxing



/* Unboxing Example */


int
 i = 10;
object
 obj = i; //boxing
int j = (int) obj; //unboxing

Int32 intObj2 = i; //boxing
j = (int) intObj2; //unboxing


References: The Frequently Asked Questions (faq) series on various programming languages are great resources to deepen knowledge in the respective languages.

Programming Language FAQC++ FAQs (2nd Edition)The Java Faq (Java Series)

Friday, December 18, 2009

Operators


This post is part of my ongoing effort to familiarize the readers with the commonalities & variabilities of C++/Java/C# programming languages. A tentative outline of this series can be found at Contents.

An Operator is a syntactic element which specifies that certain arithmetic or logical manipulation must be performed on some data. C++/Java/C# all support the basic operators of C.

Following are some lists of the operators in these languages grouped by their types. The empty cell means the operator is not directly supported by some particular language and the name in bracket besides it shows what can be used as a replacement.

Arithmetic Operators

C++
Java
C#
Meaning
Example
++
++
++
increment by 1
i++; or ++i;
--
--
--
decrement by 1
i--; or --i;
+
+
+
addition
z = x +y;
-
-
-
subtraction
z=x-y
-
-
-
negation
-x or -5
*
*
*
multiplication
z = x*y
/
/
/
division
z = x/y
%
%
%
modulus (remainder)
z = x % y
Conditional Operators

C++
Java
C#
Meaning
Example
&&
&&
&&
conditional AND
if (x && y)
||
||
||
conditional OR
if (x || y)
!
!
!
conditional NOT
 if (!x)
Logical (bitwise) Operators

C++
Java
C#
Meaning
Example
&
&
&
logical AND
z = (x & y);
| |
|
|
logical OR
z = (x | y);
^
^
^
logical XOR
 z = (x ^ y);
~
~
~
logical complement
 z = ~x;
Relational (conditional) Operators

C++
Java
C#
Meaning
Example
>
>
>
greater than
if (x > y);
>=
>=
>=
greater than or equal to
if (x >= y);
<
<
<
less than
if (x < y);
<=
<=
<=
less than or equal to
if (x > y);
==
==
==
equal to
if (x == y);
!=
!=
!=
not equal to
if (x != y);

/*Add two integers and return the result*/
int
 doSum(int x, int y)
{

    int
 x = 10;
    int
 y = 12;
  
    x++; // increment x by 1
    y--; // decrement y by 1

    return
 x + y; // return 22
}

References:

Thursday, December 17, 2009

Bangladeshi's in Rome

Our trip to Rome this week was a big surprise for my 4-year old daughter. On the time of arrival, the first conversation that took place to ask the way to taxi stand, was in Bangla. She was surprised and continuously declaring that "the uncle can speak Bangla".

Apart from the richness of Vatican City and ruins of Roman Dynasty, I was amazed by the presence of immense number of Bangladeshis in Rome. They were scattered around everywhere. We lived on Bangladeshi food during our stay there.

Thursday, December 10, 2009

"Papa, I don't want to grow up. I want to hold your hand and walk forever".
My 4-year old daughter

10 Minute Guide

Software technology is rapidly changing. New technologies are arriving every now-and-then. Getting up-to-date with all the new innovations is very challenging. There are things which you can very quickly start with. My series of posts entitled "10 Minute Guide..." will present some of these new techniques.
  1. 10 Minute Guide to Chromimum OS Installation
  2. 10 Minute Guide to Google Maps
  3. 10 Minute Guide to DirectX 11 Programming in C++

Wednesday, December 09, 2009

Just Installed Google Chrome Browser Beta for Linux

The beta versions for google chrome browser for Linux and Mac OS are out. I have just downloaded the debian/ubuntu package from chrome site. Switch to the download directory and run the following command from console:

$sudo dpkg -i google-chrome-beta_current_i386.deb

Run google chrome

$google-chrome

It is super fast!!!

10 Minute Guide to Google Maps

Map-based applications are becoming parts of our digital life. Visualizations of travel data, current news events, graphical presentation of weather reports, historical sites, concert locations, public transportation, corporate offices, and real estate sites through maps are very frequently used applications now-a-days. It is extremely simple to add map support to your web site. I have compiled here a 10 min guide for a map with a simple balloon marker on the location based on your IP.

Prerequisites: You need very basic knowledge of the following:
  1. HTML
  2. JavaScript

Step 1. Create Page: Create a new HTML page in your favorite text editor or HTML page. The page will roughly contain the following text (You can better copy these lines to a text file and save it with .htm or .html extension):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
&<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>My Location</title>
</head>
<body>

</body>
</html>

2 min.
Step 2. Add Canvas:  Add a <div> tag inside the <body> where the map will be displayed and give it an id (e.g. canvas in the following example) 

<body>
<div id="canvas" style="height: 400px; width: 400px;"></div>
</body>

2 min.
Step3. Reference maps API: Add the following <script> tag just under <title> tag. This line will set a reference to JavaScript API libraries provided by google.

<script type="text/javascript" src="http://www.google.com/jsapi"></script>
1 min.

Step4. Create Map: Load API library and initialize the map in a <script> tag inside <head> tag (or copy & paste the following lines of code).

<script type="text/javascript">

function initialize() {
    /* give a default zoom level*/
    var zoom = 8;
    /*default center of the map*/
    var latlng = new google.maps.LatLng(49.008054, 8.388969);

   /* get the your location with geocoding */
   var location;
    if (google.loader.ClientLocation) {
      latlng = new google.maps.LatLng(google.loader.ClientLocation.latitude, google.loader.ClientLocation.longitude);
     /* Build a text of the location to display */
     location = "Latitude: " + google.loader.ClientLocation.latitude + "<br/>";
     location += "Longitude: " + google.loader.ClientLocation.longitude + "<br/>";
     location +=  "City: " + google.loader.ClientLocation.address.city + "<br/>";
     if (google.loader.ClientLocation.address.region)
         location += "Region: " + google.loader.ClientLocation.address.region + "<br/>";
     location += "Country: " + google.loader.ClientLocation.address.country;
    }

    /* Options for the map*/
    var myOptions = {
      zoom: zoom,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    }

    /* Create the map on the canvas */
    var map = new google.maps.Map(document.getElementById("canvas"), myOptions);

   /* Create an info window to display the location text */
   var infowindow = new google.maps.InfoWindow({
        content: location
    });

   /* Create a default balloon marker at your location */
   var marker = new google.maps.Marker({
        position: latlng,
        map: map,
        title:"My Location"
    });
 
    /* Display the location text when marker is clicked */
google.maps.event.addListener(marker, 'click', function() {
      infowindow.open(map,marker);
    });
  }
</script>
5 min.

Browse and download the complete HTML page from here. Click the balloon on the following map to see your current location.






There are a lot of tutorials, samples and demos available at the Google Maps API web site.

Monday, December 07, 2009

Basic/Primitive Types


This post is part of my ongoing effort to familiarize the readers with the commonalities & variabilities of C++/Java/C# programming languages. A tentative outline of this series can be found at Contents.

In a previous post Identifiers, I have discussed identifiers that we can write in the source. Type restricts the identifier to size & kind of data and in addition, the operations that can be performed on that data. Both Java and C# support almost all basic data types of C++ but change characteristics of some. C++/Java/C# are strongly typed languages meaning each object must have a predefined data type.

Type Modifier:
C++ has 7 basic data types. They are int, float, double, bool, char, wchar_t, void. It uses four type modifiers to restrict the signedness and size of data that can be stored on a data type identifier -
  1. signed: Defines a positive (+ve) or negative (-ve) type. All types are implicitly positive.
  2. unsigned: A positive (+ve) type. Variable of this type can't hold negative values.
  3. short: Types are implicitly short if not otherwise specified.
  4. long: Extends the size of basic type to holder larger value.
.Net programs are compiled into Microsoft Intermediate Language (MSIL). Similar to Java Byte Code, it is  independent of hardware architecture and is translated to machine code during or before execution. But unlike Java, it brings a common type system (CTS) which means the actual program can be written in arbitrary language which can compile for .Net and the respective compiler is responsible for translating it to MSIL. MSIL defines a set of data types and each .Net compatible compiler must translate its own data types to the corresponding data types in MSIL. In other words, each data type in C# resembles a data type in MSIL.

In Java and C#, the primitive types are value types (more in Value Type vs. Reference Type and Boxing vs. Unboxing) which are allocated in the stack and copied during assignment. There are corresponding reference types in both the languages with implicit conversion from each other. The boxed types of Java are listed in "Java Boxed" and that of C# are in ".Net Type" columns.

Following is a list of the primitive data types in these languages. The sign "-" means the type is not directly supported by some particular language and the type in bracket beside it shows what can be used as a replacement.


C++
Java
Java Boxed
C#
.Net
- (unsigned char)
- (byte)
- (Byte)
byte (8)
Byte
- (signed char)
byte
Byte
sbyte (8)
SByte
int
int(32)
Integer
int (32)
Int32
unsigned int
-
-
uint (32)
UInt32
short
(short int)
short
Short
short (16)
Int16
unsigned short
-
-
ushort (16)
UInt16
long (long int)
long (64)
Long
long (64)
Int64
unsigned long
-
-
ulong (64)
UInt64
float
float
Float
float (32)
Single
double
double
Double
double (64)
Double
wchar_t
char
Character
char (16)
Char
bool
boolean
Boolean
bool (8)
Boolean
- (void*)
Object
Object
object
Object
-
-
decimal (128)
Decimal
- (std::wstring)
java.lang.String
java.lang.String
string
String

Type Qualifiers

Further keywords are used to guarantee data safety or specify data vulnerability. const

C++
Java
C#
.Net
const
final
const
-
-
-
readonly
-
volatile
-
volatile
-

Storage Class Specifiers
Further keywords are used to guarantee data safety or to specify data vulnerability.

C++
Java
C#
.Net
auto
-
-
-
register
-
-
-
static
-
-
-
extern
-
extern
-

Variables

A variable has a name and we keep some information in it. The information can be altered afterward, hence the name variable. C++/Java/C# are strongly typed languages which means each variable has a defined type i.e. you cannot assign value of a type to a variable of another type.

int textLength = 0; //defines a variable of integer type
float average = 1.0; // defines a variable of float type 

Function (aka method/routine/subroutine/operation/procedure) Names

A function or method defines a particular responsibility of the program. It has a return type and a set of parameters.

/*Add two integers and return the result*/
int
 doSum(int x, int y)
{

    return
 x + y;
}


Sunday, December 06, 2009

10 Minute Guide to Chromium OS Installation

A recent hype in the technology media is "Google Chrome OS", a new Internet based operating system by Google for Netbooks. This is a significant ingredient to Google's push for cloud computing. The search giant has already partnered with several major Netbook vendors for system equipped with this OS as early as last quarter of 2010.

I have recently tried the OS and wanted to share my experience with the readers. This post will cover a 10-minute guide for the installation of the OS and get it running in your Windows or Linux OS. Let's start with our journey-

Step 1: You need a virtual machine to run Chrome OS. For Windows systems, download free VMware player or Virtual Box. I prefer Virtual Box from Sun because it doesn't need registration and is very simple to use. The rest of the post assumes that you have also preferred virtual box over VMware Player.

For Linux, download Virtual Box from http://www.virtualbox.org/wiki/Linux_Downloads. In my Kubuntu system, as always, I needed only the apt-get command:

$: sudo apt-get install virtualbox-ose-qt
It comes under KDE Menu: Applications -> Utilities -> PC Virtualization Solutions
3 min.
Step 2: Download Chrome OS image from pirates bay torrent. If you have no torrent client installed in your system, download image from gdgt.
4 min.
Add Hard disk to Virutal Box:
  1. Start the virtual box. Click New to add new virtual machine.
  2. Give it a name. Select the OS type as Linux and version as Ubuntu.
  3. Leave other options as default. 





Now start your Chrome OS-


Login with your google account-



3 min.

Enjoy your chrome OS!!!