Sunday, October 12, 2008

Why you should'nt use you use a Old C++ Comiler

Long time back, I remember when I was learning C++, I use to work on a DOS based compiler called Turbo C++ 3.0 while was a IDE(Integrated Development Environment).
Every thing was fine until I discovered that the statement :
using namespace std;
did not had any meaning for my compiler. This perhaps was very suprizing for me as by my text book at that time (Object Oriented Programing in C++ by Robert Lafore), this was to be include it in every listings.

Actualy, namespaces was introduced in 1996. They categorized the use of a particular type of clasess and objects in different namespaces. The std namespace (std => standard) comprises of several objects as cout, cin and classes such as string, fstream etc.
As my compiler was old(1992), it did not supported namespaces.

It did not matter to me until I intend to use the string class. For those who are not aware, string class is a built in class in the header file string(not string.h, I'll explain the difference shortly), that allows you to work with strings with more efficiency than the traditional c-type strings.

My compiler also did not had the standard library i.e. I was forced to use iostream.h instead of iostream and string.h instead of string.

Whats the difference between iostream and iostream.h?
Today's modern compilers(like G++,MS-Visual C++) don't allow/advice you use iostream.h or string.h instead they insist on iostream or string header file respectively. The immediate question the reader may ask is the difference between the iostream and iostream.h. I'll brief it out as this:
The iostream.h was the header file written by say, Bjarne Stroustrup, the creator of C++, and was distributed along the first c++ compiler. Later, different c++ compilers came up with different iostream.h and thus the language became compiler dependent.
Thus, to make C++ compiler independent, the need of standardisation was felt. Thus the C++ Standards Committee decided to cut the extension. This allowed the compiler companies to distribute their iostream.h along with the standard iostream.(for more detail about this topic, one can refer

Now and thus, the said limitations forced me to find another compiler.

I then started using G++, and still use it. I recommend the use of G++ for some prominent reasons.

First of all, this the very standard compiler to date. Secondly, it is licensed under GPL and is free to use. It is cross-platform, i.e. you can make application under various operation systems like Windows, Linux etc. without(or with minimum) changing of your code.

My problem was thus sort out by shifting to a standard compiler and so do I advice everyone to use a standard compiler.

I am not against Turbo C++ 3.0 in the respect of its performance. But it is not a future compiler( forget future, it is not a present day compiler). Borland, the creator company of Turbo C++ does not make Turbo C++ anymore. They are with a new product called C++ Builder which is a decent/good compiler under $100. But my choice remains g++.
Why spend money on something when you can get a thing better than that for free.