C is a general purpose computer programming language. It was originally created by Dennis M. Ritchie (circa 1971) for the specific purpose of rewriting much of the Unix operating system. This now famous operating system was at that time in its infancy: it had recently been written for a discarded DEC PDP - 7 computer by Ken Thompson, an electrical engineer and a colleague of Ritchie's at Bell Labs. Thompson had written the first UNIX in a language he chose to call B. The intention of these programmers was to port UNIX on to other, architecturally dissimilar machines. Clearly, using any assembly language was out of the question: what was required was a language that would permit assembly-like (i.e. low or hardware level) operations, such as bit manipulation, and at the same time be run able on different computers. None of the languages then available could have served the purpose: a new one was called for, and C was born. The rest is history: UNIX became spectacularly successful, in large measure because of its portability, and C, in which most of it was written, has since come to occupy a pre-eminent position in die development of systems programs.
The success of UNIX, and the consequent popularity of C for systems programming, forced it on the attention of applications programmers, who came to appreciate the rich variety of its operators and its control structures. These enable, and in fact encourage, the practice of modular programming: the individual sub-tasks that make up a large program can be written in independent blocks or modules, each of manageable size. In other words, the language possesses features which make possible a "divide and conquer" approach to large programming tasks. When programs are organized as modules they are necessarily well-planned, because each module contains only the instructions for a well-defined activity. Such programs are therefore more easily comprehensible by other readers than unstructured programs.
Another desirable, quality of modular Programs is that they may be modified without much difficulty. If changes are required, only a few modules may be affected, leaving the remainder of the program intact.
And last but not least, such programs are easier to debug, because errors can be localized to modules, and removed. For a concrete example suppose that you have to write a program to determine all prime numbers up to ten million which are of the form k * k + 1, where k is an integer (2, 5, 17 and 37 are trivial examples of such primes). Then one module of the program could be written to generate the number k * k + 1 for the next admissible value of k; and another module to test whether the last number generated is a prime. Organized in this way, not only will the program be elegant, it would also be easy to debug, understand or modify.
0 comments:
Post a Comment