Tuesday, October 24, 2006

Why isn't a product called C++ created?

The title of this post refers to my love - hate relationship with C++. C++ is an extremely flexible, effective, useful, widely spread and powerful generic and object-oriented programming language. At the same time it's frustrating, illogical, badly documented and poorly compatible language. The compilers work differently, the standard library isn't a standard, some of the compiler errors result in cryptic error messsages, C++ used in Symbian related projects doesn't even look like C++ etc. C++ was used very much in the 90s, but nowadays you can find it mainly in embedded systems and Linux programs.

I feel that C++ has mainly been forgotten because it was created to be an object-oriented programming language instead of a product. Bjaerne Stroustrup may be good at developing programming languages, but he seems to be bad in commercializing. I started programming with Java and I got used to standard compilers, cross-platfrom compatibility, very good up-to-date documentation and clear syntax. Then I moved to C/C++ world where even using different compiler may result in failure of the build and where standard doesn't mean that compilers could handle it. The C++ that is not clearly documented in any place and even if it is documented, the documentation may not be compatible with your compiler.

This is extremely frustrating when preparing for a C++ course in which we use different programming environments requested by customer. Checking all the answers with the new compiler and verifying that the needed examples work well with it. In case of extremely bad luck, I'm requested to use Visual C++ 6.o as a tool when teaching how to use templates and Standard Template Libraries. Too bad, the compiler in this case has a few bugs and some features won't simply work with this otherways fine (and old) Microsoft product.

Why, even nowadays, aren't all compilers compatible even though C++ has been standardized? I guess there are few reasons: first of all the standardization took long and was ready at 1998 when Java was emerging and C++ was seen as an old technique. The compiler creators didn't want to invest any more money to make it compatible. Also the people using the compilers already available had learned to cope with the problems. Second reason might be that nowadays the usage of C++ is very much limited to embedded systems. These are very often build on older hardware and this usally means that older programming environment is used. And of course this may mean non-standard compilers. Third reason may be just simple lack of skills. C++ standard required things like templates, RTTI and a collection of useful generic algorithms and collections, STL. These are not simple techniques and as an indication of that at least MS Visual Studio 2003 still seems to have some problems with templates.

I'm glad that Sun has resolved this kind of irrelevant problems in advance and they have relased a product called Java. Java is easy to learn, flexible, compatible, well documented and fairly efficient. I guess the developers have enough problems to solve when developing software so the last thing they want is to have problems with programming language or environment. The focus should be on software design, not finding ways to bypass compiler related problems.

No comments: