C, C++ and C# – A Reality Check

Dilip Gupta and Karan W

It is almost 45 years since Ken Thompson and Dennis Ritchie wrote a program that is said to be the first C compiler. Fifteen years from that date, in the year 1985 we saw the first commercial C++ compiler in the market place. And exactly 15 years from that date, we saw the advent of C#.

Five years hence, we take a look at where the three prominent ‘C’ languages stand. Well, we have missed out on Cobol another famous language that incidentally starts with C. But there seems to be a pattern that affects the fortunes of these three languages— C, C++, C#.
In this article we take a look at the state of the three languages that have inspired millions of developers that has captured the imagination of coders who have created some of the most amazing programs.

While proponents of each language will paint a future where every other language will disappear and his/her favorite language will be the most popular, it is important for us to look beyond the hype and try to understand where each language is positioned and what lies ahead of each of these languages.

For the moment we will ignore all the other languages and check these three ‘C’ languages.

Plain old C

If you consider all the commercial and non commercial applications available globally, and manage to browse through the code base of each application, you are likely to find more C code than any other language. Take for example Linux, average Linux distributions have on an average 71% of C code. 85% of all code contributed by Berkeley University is written in C.
There is so much of C code out there. And more importantly there is no application where C cannot be used. Applications written in C run faster than those written in any other language.

C still makes sense
1) Writing some parts of your code to run faster ( can be embedded and extended with many languages such as Perl, Python, Ruby)
2) Writing most system level applications
3) Most hardware related and embedded applications
In fact for sheer efficiency most software has a few lines of code in C.

A Reality check

ANSI and the ISO ratified the newest draft of the C standard in 1999 and unleashed the biggest changes to the language to date. New keywords, library functions, and macros are just the tip of the iceberg when it comes to the new improved C. In fact, the language is so different it is no longer compatible with C++. This article attempts to give an overview of the major changes made to the C language and also attempts to discover why no one yet seems to be affected by the new standard.

The C programming language began to be standardized some time around 1985 by the ANSI X3J9 committee. Several years of effort went by, and in 1989 ANSI approved the new standard. An ISO committee ratified it a year later in 1990 after adding an amendment dealing with internationalization issues. The 1989 C standard is known officially as ANSI/ISO 9899-1989, Programming Languages - C, and this document refers to the 1989 C standard as C89. The 1990 ISO revision of the standard is known officially as ISO/IEC 9899-1990, Programming Languages - C, which is referred to in this document as "C90".

The next version of the C standard was ratified by ISO in 1999. Officially know as ISO/IEC 9899-1999, Programming Languages - C, it is referred to in this document as "C99".

The C++ programming language was based on the C programming language as it existed shortly after the ANSI C standardization effort had begun. Around 1995 an ISO committee was formed to standardize C++, and the new standard was ratified in 1998, which is officially known as ISO/IEC 14882-1998, Programming Languages - C++. It is referred to in this document as "C++98" or simply as "C++".

Though the two languages share a common heritage, and though the designers involved in the standardization processes for each language tried to keep them as compatible as possible, some incompatibilities unavoidably arose. Once the programmer is aware of these potential problem spots, they are easy, for the most part, to avoid when writing C code. Due to popularity of GC compiler for writing C code, most vendors have stayed away from commercial C compiler markets. Instead they have focused on the more lucrative C++ and Java IDEs.

The future of C

There is little doubt that C will survive and will be around for a long time. There is no solution to replace the huge chunks of code in applications today. And these code base need to be maintained.

Since C++ is the object oriented version of C, it is likely that more projects will be written in C++. The threat from Java is very real. The presence and growth of languages like Perl, PHP and Python presents a threat and opportunity. With faster computers writing even mission critical applications in these languages is no more a risk. At the same time C is used to extend these languages.

Two decades of C++

C++ was in many ways almost killed by Java. Once up on a time 76% of developers were writing code in C++ and was coming to terms with this language, which was at best an updated version of C. However Microsoft and Borland backed the language during the nineties and the language was used once upon a time to build almost all the products from Microsoft.

The advent of Java saw tremendous amount of C++ bashing. It became a fashion to ridicule the many warts and predicaments surrounding C++. In fact during the heights of the Dot Net Boom, many C++ conferences which used to run to packed audiences where cancelled.
Suddenly C++ became a language that was disliked by many. However in the past couple of years, the interest in C++ has returned as reality struck many developers. We will sketch the return of C++ and where it is positioned in the new world where it is challenged by C# in the next article.

History of C/C++

During the 60s appeared some new programming languages, like ALGOL 60 that gathered from FORTRAN the concepts of structured programming which finally would be used by CPL and its succesors (like C++). Later ALGOL 68 also influenced directly in the development of data types in C. Nevertheless ALGOL was an unspecific language and its abstraction made it little practical to solve habitual tasks.

In 1963 it appeared the CPL (Combined Programming language) with the idea of being more specific for concrete programming tasks of that time than ALGOL. Nevertheless this same specificity made it a very great language and, therefore, difficult to learn and to implement.
In 1967, Martin Richards developed the BCPL (Basic Combined Programming Language), that signicated a simplification of the CPL taking the best things that this language offered. But it continued being a very abstract language, that made it portable little but little adapted to the peculiarities of a concrete machine.

In 1970, Ken Thompson, immersed in the development of UNIX at Bell Labs, created the B language. It was a port of BCPL for a specific machine and system (DEC PDP-7 and UNIX), and was adapted to his particular taste and necessities. The final result was a even greater simplification of CPL although dependent on the system. It had great limitations like it did not compile to executable code but threated-code, which generates slower code in execution, and therefore inadequate for the development of an operating system with this language. Reason why from 1971, Denis Ritchie, from the Bell Labs team, began the development of a B compiler whom, among other things, was able to generate executable code directly. This "New B", finally called C, introduced in addition, some other new concepts to the language like data types (char).

Early 1973, Denis Ritchie, had developed the bases of C. The inclusion of types, its handling, as well as the improvement of arrays and pointers, along with later demonstrated capacity of portability without for that reason become a high-level language, contributed to the expansion of the C. It was established with the book "The C Programming Language" by Brian Kernighan and Denis Ritchie, known as White Book, and that served as de facto standard until the publication of formal ANSI standard (ANSI X3J11 committee) in 1989.
Early 1980, Bjarne Stroustrup, from Bell labs, began the development of the C++ language, that would receive formally this name at the end of 1983, when its first manual was going to be published. In October 1985, appeared the first commercial release of the language and the first edition of the book "The C++ Programming Language" by Bjarne Stroustrup.

During the 80s the C++ language was being refined until it became a language with its own personality. All that without practically loss of compatibility in the code neither to resign to its most important characteristics. In fact the ANSI standard for the C language published in 1989 gathered good part of the contributions of C++ to the structured programming.

From 1990, ANSI committee X3J16 began the development of an own standard for C++. In the period passed until the publication of the standard's final draft in November 1997, C++ lived a great expansion in their use and nowadays it is the most used language in the delopment of applications. Also until the publication of the standard, the C++ language has lived great changes and has incorporated new concepts.