|
C is a general-purpose, procedural, imperative computer programming language developed in 1972 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system. It has since spread to many other platforms, and is now one of the most widely used programming languages. C has also greatly influenced many other popular languages, especially C++, which was originally designed as an enhancement to C. It is the most commonly used programming language for writing system software, though it is also widely used for writing applications Philosophy
C is a minimalistic programming language. Among its design goals were that it could be compiled in a straightforward manner using a relatively simple compiler, provide low-level access to memory, generate only a few machine language instructions for each of its core language elements, and not require extensive run-time support. As a result, C code is suitable for many systems-programming applications that had traditionally been implemented in assembly language. Despite its low-level capabilities, the language was designed to encourage machine-independent programming. A standards-compliant and portably written C program can be compiled for a very wide variety of computer platforms and operating systems with minimal change to its source code. The language has become available on a very wide range of platforms, from embedded microcontrollers to supercomputers. Characteristics
C is a procedural programming paradigm, with facilities for structured programming. It allows lexical variable scope and recursion. Its static type system prevents many meaningless operations. Parameters of C functions are always passed by value. Pass-by-reference is achieved in C by explicitly passing pointer values. Heterogeneous aggregate data types (the struct in C) allow related data elements to be combined and manipulated as a unit. C has a small set (around 30) of reserved keywords. C exhibits the following specific characteristics: · Weak typing — for instance, characters can be used as integers (similar to assembly) · Low-level access to computer memory via machine addresses and typed pointers · Function pointers allow for a rudimentary form of closures and runtime polymorphism · Array indexing as a secondary notion, defined in terms of pointer arithmetic · A standardized C preprocessor for macro definition, source code file inclusion, conditional compilation, etc. · A simple, small core language, with functionality such as mathematical functions and file handling delegated to library routines · Free-format source text, using semicolon as a statement terminator (not a delimiter as in Pascal) · A large number of tokens constructed from no alphanumeric symbols, for example { ... } rather than Algol's begin ... end · Use of && and || for logical "and" and "or", which · are syntactically distinct from C's bit-wise operations (& and |) — C's predecessor B used & and | for both meanings · never evaluate the right operand if the result can be determined from the left alone ("short-circuit" or Minimal evaluation) · · Follows FORTRAN's decision to use a single equal-sign to denote assignment, using == as the operator for comparing for equality (inherited from B) History
Early developments
The initial development of C occurred at AT&T Bell Labs between 1969 and 1973; according to Ritchie, the most creative period occurred in 1972. It was named "C" because many of its features were derived from an earlier language called "B," which according to Ken Thompson was a stripped down version of the BCPL programming language. There are many legends as to the origin of C and the closely related Unix operating system, including these: · The development of Unix was the result of programmers' desire to play the Space Travel computer game. They had been playing it on their company's mainframe, but as it was underpowered and had to support about 100 users, Thompson and Ritchie found they did not have sufficient control over the spaceship to avoid collisions with the wandering space rocks. This led to the decision to port the game to an idle PDP-7 in the office. As this machine lacked an operating system, the two set out to develop one, based on several ideas from colleagues. Eventually it was decided to port the operating system to the office's PDP-11, but faced with the daunting task of translating a large body of custom-written assembly language code, the programmers began considering using a portable, high-level language so that the OS could be ported easily from one computer to another. They looked at using B, but it lacked functionality to take advantage of some of the PDP-11's advanced features. This led to the development of an early version of the C programming language. · The justification for obtaining the original computer to be used in developing the Unix operating system was to create a system to automate the filing of patents. The original version of the Unix system was developed in assembly language. Later, nearly all of the operating system was rewritten in C, an unprecedented move at a time when nearly all operating systems were written in assembly. By 1973, the C language had become powerful enough that most of the Unix kernel, originally written in PDP-11 assembly language, was rewritten in C. This was one of the first operating system kernels implemented in a language other than assembly. (Earlier instances include the Multics system (written in PL/I), and MCP (Master Control Program) for the Burroughs B5000 written in ALGOL in 1961.) K&R C
In 1978, Dennis Ritchie and Brian Kernighan published the first edition of The C Programming Language. This book, known to C programmers as "K&R", served for many years as an informal specification of the language. The version of C that it describes is commonly referred to as "K&R C". The second edition of the book covers the later ANSI C standard. K&R introduced several language features: · struct data types · long int data type · unsigned int data type · The =- operator was changed to -= to remove the semantic ambiguity created by the construct i=-10, which could be interpreted as either i =- 10 or i = -10 For many years after the introduction of ANSI C, K&R C was still considered the "lowest common denominator" to which C programmers restricted themselves when maximum portability was desired, since many older compilers were still in use, and because carefully written K&R C code can be legal ANSI C as well. In early versions of C, only functions that returned a non-integer value needed to be declared if used before the function definition; a function used without any previous declaration was assumed to return an integer. For example: long int SomeFunction(); int OtherFunction(); int CallingFunction() { long int test1; int test2; test1 = SomeFunction(); if (test1 > 0) test2 = 0; else test2 = OtherFunction(); return test2; } Since K&R function declarations did not include any information about function arguments, function parameter type checks were not performed, although some compilers would issue a warning message if a local function was called with the wrong number of arguments, or if multiple calls to an external function used different numbers of arguments. Separate tools such as Unix's lint utility were developed that (among other things) could check for consistency of function use across multiple source files. In the years following the publication of K&R C, several unofficial features were added to the language (since there was no standard), supported by compilers from AT&T and some other vendors. These included: · void functions · Functions returning struct or union types (rather than pointers) · Assignment for struct data types · const qualifier to make an object read-only · Enumerated types The large number of extensions and lack of a standard library, together with the language popularity and the fact that not even the Unix compilers precisely implemented the K&R specification, led to the necessity of standardization. ANSI C and ISO C
During the late 1970s, C began to replace BASIC as the leading microcomputer programming language. During the 1980s, it was adopted for use with the IBM PC, and its popularity began to increase significantly. At the same time, Bjarne Stroustrup and others at Bell Labs began work on adding object-oriented programming language constructs to C, resulting in the language now called C++. In 1983, the American National Standards Institute (ANSI) formed a committee, X3J11, to establish a standard specification of C. In 1989, the standard was ratified as ANSI X3.159-1989 "Programming Language C." This version of the language is often referred to as ANSI C, Standard C, or sometimes C89. In 1990, the ANSI C standard (with a few minor modifications) was adopted by the International Organization for Standardization (ISO) as ISO/IEC 9899:1990. This version is sometimes called C90. Therefore, the terms "C89" and "C90" refer to essentially the same language. One of the aims of the C standardization process was to produce a superset of K&R C, incorporating many of the unofficial features subsequently introduced. However, the standards committee also included several new features, such as function prototypes (borrowed from C++), void pointers, support for international character sets and locales, and a more capable preprocessor. The syntax for parameter declarations was also augmented to include the C++ style:
int main(int argc, char **argv) { ... } although the K&R interface int main(argc, argv) int argc; char **argv; { ... } although the K&R interface int main(argc, argv) continued to be permitted, for compatibility with existing source code. C89 is supported by current C compilers, and most C code being written nowadays is based on it. Any program written only in Standard C and without any hardware-dependent assumptions will run correctly on any platform with a conforming C implementation, within its resource limits. Without such precautions, programs may compile only on a certain platform or with a particular compiler, due, for example, to the use of non-standard libraries, such as GUI libraries, or to a reliance on compiler- or platform-specific attributes such as the exact size of data types and byte endianness. In cases where code must be compilable by either standard-conforming or K&R C-based compilers, the __STDC__ macro can be used to split the code into Standard and K&R sections, in order to take advantage of features available only in Standard C. #ifdef __STDC__ extern int getopt(int,char * const *,const char *); #else extern int getopt(); #endif In the above example, a compiler which has defined the __STDC__ macro (as mandated by the C standard) only interprets the line following the ifdef command. In other, nonstandard compilers which don't define the macro, only the line following the else command is interpreted.
|

|
The C Programming Language, Brian Kernighan and Dennis Ritchie, the original edition that served for many years as an informal specification of the language. |
|
|
Paradigm: |
imperative (procedural) systems implementation language |
|
Appeared in: |
1972 |
|
Designed by: |
Dennis Ritchie |
|
Developer: |
Dennis Ritchie & Bell Labs |
|
Typing discipline: |
static, weak |
|
Major implementations: |
GCC, MSVC, Borland C, WatcomC |
|
Dialects: |
ObjC, C++ |
|
Influenced by: |
B (BCPL,CPL), ALGOL 68, Assembly, Pascal |
|
Influenced: |
Awk, csh, C++, C#, ObjC, BitC, D, Concurrent C, Java, Javascript |