29-10-2012, 04:08 PM
C The Complete Reference
C The Complete.pdf (Size: 5.53 MB / Downloads: 36)
A Brief History of C
C was invented and first implemented by Dennis Ritchie on a DEC PDP-11 that used the Unix
operating system. C is the result of a development process that started with an older language called
BCPL. BCPL was developed by Martin Richards, and it influenced a language called B, which was
invented by Ken Thompson. B led to the development of C in the 1970s.
For many years, the de facto standard for C was the version supplied with the Unix operating
system. It was first described in The C Programming Language by Brian Kernighan and Dennis
Ritchie (Englewood Cliffs, N.J.: Prentice-Hall, 1978). In the summer of 1983 a committee was
established to create an ANSI (American National Standards Institute) standard that would define
the C language. The standardization process took six years (much longer than anyone reasonably
expected).
The ANSI C standard was finally adopted in December 1989, with the first copies becoming
available in early 1990. The standard was also adopted by ISO (International Standards
Organization), and the resulting standard was typically referred to as ANSI/ISO Standard C. In
1995, Amendment 1 to the C standard was adopted, which, among other things, added several new
library functions. The 1989 standard for C, along with Amendment 1, became a base document for
Standard C++, defining the C subset of C++. The version of C defined by the 1989 standard is
commonly referred to as C89.
During the 1990s, the development of the C++ standard consumed most programmers' attention.
However, work on C continued quietly along, with a new standard for C being developed. The end
result was the 1999 standard for C, usually referred to as C99. In general, C99 retained nearly all of
the features of C89. Thus, C is still C! The C99 standardization committee focused on two main
areas: the addition of several numeric libraries and the development of some special-use, but highly
innovative, new features, such as variable-length arrays and the restrict pointer qualifier. These
innovations have once again put C at the forefront of computer language development.
C Is a Middle-Level Language
C is often called a middle-level computer language. This does not mean that C is less powerful,
harder to use, or less developed than a high-level language such as BASIC or Pascal, nor does it
imply that C has the cumbersome nature of assembly language (and its associated troubles). Rather,
C is thought of as a middle-level language because it combines the best elements of high-level
languages with the control and flexibility of assembly language. Table 1-1 shows how C fits into the
spectrum of computer languages.
As a middle-level language, C allows the manipulation of bits, bytes, and addresses— the basic
elements with which the computer functions. Despite this fact, C code is also very portable.
Portability means that it is easy to adapt software written for one type of computer or operating
system to another type. For example, if you can easily convert a program written for DOS so that it
runs under Windows 2000, that program is portable.
C Is a Structured Language
In your previous programming experience, you may have heard the term block-structured applied to
a computer language. Although the term block-structured language does not strictly apply to C, C is
commonly referred to simply as a structured language. It has many similarities to other structured
languages, such as ALGOL, Pascal, and Modula-2.
C Is a Programmer's Language
Surprisingly, not all computer programming languages are for programmers. Consider the classic
examples of nonprogrammer languages, COBOL and BASIC. COBOL was designed not to better
the programmer's lot, not to improve the reliability of the code produced, and not even to improve
the speed with which code can be written. Rather, COBOL was designed, in part, to enable
nonprogrammers to read and presumably (however unlikely) to understand the program. BASIC was
created essentially to allow nonprogrammers to program a computer to solve relatively simple
problems.
In contrast, C was created, influenced, and field-tested by working programmers. The end result is
that C gives the programmer what the programmer wants: few restrictions, few complaints, block
structure, stand-alone functions, and a compact set of keywords. By using C, you can nearly achieve
the efficiency of assembly code combined with the structure of Pascal or Modula-2. It is no wonder
that C has become the universal language of programmers around the world.
The fact that C can often be used in place of assembly language was a major factor in its initial
success. Assembly language uses a symbolic representation of the actual binary code that the
computer executes directly. Each assembly-language operation maps into a single task for the
computer to perform. Although assembly language gives programmers the potential to accomplish
tasks with maximum flexibility and efficiency, it is notoriously difficult to work with when
developing and debugging a program. Furthermore, since assembly language is unstructured, the
final program tends to be spaghetti code— a tangled mess of jumps, calls, and indexes. This lack of
structure makes assembly-language programs difficult to read, enhance, and maintain. Perhaps more
important, assembly-language routines are not portable between machines with different CPUs.
Compilers vs. Interpreters
It is important to understand that a computer language defines the nature of a program and not the
way that the program will be executed. There are two general methods by which a program can be
executed. It can be compiled, or it can be interpreted. Although programs written in any computer
language can be compiled or interpreted, some languages are designed more for one form of
execution than the other. For example, Java was designed to be interpreted, and C was designed to
be compiled. However, in the case of C, it is important to understand that it was specifically
optimized as a compiled language. Although C interpreters have been written and are available in
some environments (especially as debugging aids or experimental platforms like the interpreter
developed in Part Six of this book), C was developed with compilation in mind. Therefore, you will
almost certainly be using a C compiler and not a C interpreter when developing your C programs.
Since the difference between a compiler and interpreter may not be clear to all readers, the following
brief description will clarify matters.