User:Blacken~enwikibooks/C++ Concepts and Programming/Introduction to C

= An Introduction to C =

This chapter will begin a brief explanation of the C programming language (the most direct precursor to C++). You'll write your first code in this chapter and learn about compiling your code so that it will run.

A Brief History of C

 * ''...the history of Time just happened to wander in by accident. Still hasn't found its way out.

ALGOL

 * "Here is a language so far ahead of its time, that it was not only an improvement on its predecessors, but also on nearly all its successors."
 * -Sir C. A. R. Hoare

In the beginning, far back in the mists of computer history (about fifty years or so) there was ALGOL, short for ALGOrithmic Language. ALGOL is a family of imperative computer languages that were originally designed to avoid the pitfalls of another language of the time, FORTRAN (which finds some very limited use still today). The language was designed and developed by a committee of American and European computer scientists. The most well-known version, the one referred to by the above quote by Sir C. A. R. Hoare, was ALGOL 60, a specification for which was released in 1960. ALGOL was designed to be as minimalistic as possible; the standard did not even specify a way for programs to accept user input. (Oops.)

A later version of ALGOL, termed ALGOL 68 (released in 1968--I see a pattern here!), expanded on the language extensively, earning the ire of the aforementioned Hoare and the computer science luminary Edsger Djikstra for losing the simplicity that made ALGOL 60 a good language to use. ALGOL 68 found some use in European military technology and, if not for the Department of Defense's Ada, might have found use in the United States. As it happened, ALGOL 68 had few fans in the United States.

CPL, BCPL, and B
The CPL, or Combined Programming Language, came out of a partnership between Cambridge University and the University of London in the 1960s. (Hence the "combined" in the name; previously it was the Cambridge Programming Language.) CPL showed heavy influences from the ALGOL series of languages, but lacked the simplicity and elegance of ALGOL 60. Unlike its illustrious predecessor, CPL was too complex and heavy for computers of the time and never had much of a following. By the time computers could reliably handle the language, its time had passed entirely.

The BCPL, or Basic CPL, grew out of the ashes of the CPL. BCPL came with an interesting idea--the CPL was a good language, but had many parts that made writing a compiler difficult but did not provide any real benefit to the programmers. Where CPL never found a niche where it could be used, BCPL quickly found a home in systems programming. BCPL had a curious feature (some might argue "misfeature"): there were no primitive data types--no, no strings (though that same variable could be used as a character, allowing you to build strings of text out of many of these variables). From BCPL came B, written by Ken Thompson of Bell Labs. Thompson took out any component that he thought he could do without--otherwise the language would not fit into the memory-constrained minicomputers of the time.

C

 * Oooooooh, aaaah.

There are a lot of urban legends around the creation of C. The language was based at least in large part on Thompson's B programming language. It was called "C" because it was derived from Thompson's earlier B; programmers really are logical folks (some of the time). It began with the creation of the Unix operating system.

Unix was originally designed by a number of AT&T employees at Bell Labs; some of the culprits include Dennis Ritchie, Ken Thompson, Brian Kernighan, and Douglas McIlroy. During the 1960s, AT&T, General Electric, and the Massachusetts Institute of Technology used an operating system called Multics on GE-645 mainframe computers. Eventually AT&T pulled out, but Thompson continued to develop for the GE-645. He wrote a game called Space Travel on it, but discovered (no doubt to his chagrin) that each play of the game cost almost $75 in computer time. So Thompson rewrote the game for the state-of-the-art DEC PDP-7. This pushed him to lead a team at Bell Labs to write the Unix operating system (its name a pun on Multics), but in assembly language--C had not been invented yet, after all.

The state-of-the-art PDP-7 was soon no longer state-of-the-art, supplanted by the PDP-11. The Unix operating system that the Bell Labs engineers had coded in assembly language was not portable, so the team at Bell Labs decided to rewrite Unix in a high-level language so they could use it on multiple computer systems without having to rewrite it every time. Instead, all that would need to be written is the compiler to take the high-level language's source code and turn it into machine code. They looked at Thompson's B programming language, but it lacked needed functionality. Thus, the project to write the language that became C was born. By 1973, C had matured to the point that most of the Unix kernel had been rewritten in C.

By the late 1970s, C was the leading programming language for microcomputers. Until 1989, though, every compiler acted slightly different; the same code might not compile with two different companies' compilers. The ANSI C standard was ratified in 1989 (and became an ISO standard in 1990), though, and compiler writers slowly began the process of standardizing their compilers.

The updated ISO C99 standard was published in 1999 and, in a fitting turnabout, was ratified by the ANSI a year later. It actually contained a number of inclusions that actually stemmed from C++ (whose history branching from C will be covered later).