C is a programming language designed by Dennis Ritchie during the early 1970s for writing the UNIX operating system. C remains the most widely used language for writing system software, and C is also used for writing applications.
Features The main features of C are:
- Focus on the procedural programming paradigm, with facilities for programming in a structured style.
- Access to low level hardware via the use of pointers to refer to locations in memory.
- Parameters are always passed to functions by value, not by reference.
- Lexical variable scoping (but no support for closures or functions defined within functions.)
- A standardized set of library routines, which provide features that are useful but not strictly essential.
- Use of a preprocessor language, the C preprocessor, for tasks such as defining macros and including multiple source code files.
- O(1) performance for all operators
The functionality of C is guaranteed by the ANSI/ISO C89/90 and C99 standards
documents, which explicitly specify when the compiler (or environment) shall
issue diagnostics. The documents also specify what behavior one can expect from
C code that conforms to the standard.
For example, the following code, according to the standard, produces
undefined behavior.
#include <stdio.h>
#include <string.h>
int main (void) {
char *s = "Hello World!\n";
strcpy (s, s+1); /* remove first character from string s --
s = s+1;
is probably what the programmer wanted
*/
return 0;
}
"Undefined behavior" means that the resulting program can do anything,
including working as the programmer intended it to, crashing horribly every time
it is run, or insidously crashing only every 42nd time the program is run, or
crashing whenever the machine is rebooted, etc., ad nauseam.
Some compilers do not adhere to either of the standards in their default
mode, which leads to many programs being written which will only compile with a
certain version of a certain compiler on a certain platform.
Any program written *only* in standard C will compile unchanged on any
platform which has a conforming C implementation.
Although C is usually termed a high level language, it is only a
"higher-level" language when compared to assembly language,
and is significantly lower-level than most other programming languages. Most
prominently, it is up to the programmer to manage the contents of computer memory. C
provides no facilities for array bounds checking or automatic garbage
collection.
Manual memory management provides the programmer with greater leeway in tuning the performance of a program, which is particularly important for programs such as device drivers. However, it also makes it easy to accidentally create code with bugs stemming from erroneous memory operations, such as buffer overflows. Tools have been created to help programmers avoid these errors, including libraries for performing array bounds checking and garbage collection, and the lint source code checker. Intentional exploitation of programs written in C containing unguarded buffer overrun potential is the mechanism used by many computer virus and computer worm designers.
Some of the perceived shortcomings of C have been addressed by newer programming languages derived from C. The Cyclone programming language has features to guard against erroneous memory operations. C++ and Objective C provide constructs designed to aid object-oriented programming. Java and C# add object-oriented programming constructs as well as a higher level of abstraction, such as automatic memory management.
History
The initial development of C occurred between 1969 and 1973 (according to Ritchie, the most creative period was during 1972). It was called "C" because many features derived from an earlier language named B, which itself was a revision of an earlier language bon, named after Ken Thompson's wife Bonnie.
By 1973, the C language had become powerful enough that most of the kernel of the Unix operating system was reimplemented in C, perhaps following the examples of the Multics system (implemented in PL/I), Tripos (implemented in BCPL), and perhaps others. In 1978, Ritchie and Brian Kernighan published The C Programming Language (a.k.a. "the white book", or K&R.) For many years, this book served as the specification of the language; even today, it enjoys great popularity as a manual and learning tutorial.
C became immensely popular outside Bell Labs during the 1980s,
and was for a time the dominant language in systems and microcomputer
applications programming. It is still the most commonly-used language in systems
programming, and is one of the most frequently used programming languages in
computer science education.
In the late 1980s, Bjarne Stroustrup and
others at Bell Labs worked to add object-oriented programming
language constructs to C. The language they produced with Cfront was called C++ (thus avoiding the issue of whether the successor to "B" and "C" should be "D" or "P".) C++ is now
the language most commonly used for commercial applications on the Microsoft Windows operating system, though C remains more popular in the Unix world.
This article is licensed under the GNU Free Documentation License. It uses material from the Wikipedia article "C programming language".
|