Paradigm(s) | Imperative (procedural),structured |
---|---|
Appeared in | 1972[2] |
Designed by | Dennis Ritchie |
Developer | Originally: Dennis Ritchie & Bell Labs ANSI C: ANSI X3J11 ISO C:ISO/IEC JTC1/SC22/WG14 |
Stable release | C11 (December 2011) |
Typing discipline | Static, weak, manifest,nominal |
Major implementations | Clang, GCC, Intel C,MSVC, Turbo C, Watcom C |
Dialects | Cyclone, Unified Parallel C,Split-C, Cilk, C* |
Influenced by | B (BCPL, CPL), ALGOL 68,[3] Assembly, PL/I,FORTRAN |
Influenced | Numerous: AMPL, AWK,csh, C++, C--, C#,Objective-C, BitC, D, Go,Java, JavaScript, Limbo,LPC, Perl, PHP, Pike,Processing |
OS | Cross-platform (multi-platform) |
History
The initial development of C occurred at AT&T Bell Labs between 1969 and 1973;[3] according to Ritchie, the most creative period occurred in 1972. It was named "C" because 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.
The origin of C is closely tied to the development of the Unix operating system, originally implemented in assembly language on a PDP-7 by Ritchie and Thompson, incorporating several ideas from colleagues. Eventually they decided to port the operating system to a PDP-11. B's inability to take advantage of some of the PDP-11's features, notably byte addressability, led to the development of an early version of C.
The original PDP-11 version of the Unix system was developed in assembly language. By 1973, with the addition of
struct
types, the C language had become powerful enough that most of the Unix kernel 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, Brian Kernighan and Dennis Ritchie published the first edition of The C Programming Language.[8] 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[1] covers the later ANSI C standard.
K&R introduced several language features:
- standard I/O library
long int
data typeunsigned int
data type- compound assignment operators of the form
=
op (such as=-
) were changed to the form op=
to remove the semantic ambiguity created by such constructs asi=-10
, which had been interpreted asi =- 10
instead of the possibly intendedi = -10
Even after the publication of the 1989 C standard, for many years 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 Standard C as well.
In early versions of C, only functions that returned a non-int
value needed to be declared if used before the function definition; a function used without any previous declaration was assumed to return type int
, if its value was used. C Programming Notes
Notes to Accompany The C Programming Language, by Kernighan and Ritchie (``K&R'') Steve Summit
The C Programming Language, or K&R as it is affectionately known, is widely praised by experienced C programmers as one of the best books on C there is. (It was also the first; it also happens to be a best-seller.) The only real criticism K&R ever receives is that it may not be the best tutorial for beginners; it seems to assume a certain amount of programming savvy and familiarity with computers. Actually, if you read it carefully, you'll find that is constantly dispensing wisdom about programming in general, from basic concepts to deep insights to impeccable commentary on imponderable topics such as programming style, at the same time it teaches the specifics of the C language. Therefore, the fundamental criticism may simply be that K&R is not suitable for those who read carelessly.
The authors are not out to save the world or to convert it to their philosophy of programming. When they say something, they say it once, without theatrics or undue emphasis. If you read the book too quickly, or skim it, or look only for specific answers to what you think you're trying to learn today, you will miss much of the excellent advice which the authors have to offer.
These notes were prepared (beginning in Spring, 1995) for the University of Washington Experimental College course in Introductory C Programming. They are meant to supplement K&R for the reader who is new to C and perhaps to programming, and who wants a slightly more detailed, less pithy presentation. I'll add insights from my own experience, in particular by pointing out those areas where people traditionally misunderstand something about C or K&R's presentation of it. I'll also call out a few of the very deep sentences, which you might overlook at first even if you're not skimming (perhaps because their significance only becomes apparent once you've begun writing bigger or more complicated programs), but which contain advice which is absolutely vital to successful real-world programming and which, if you can take it to heart early, will save you from a lot of misery out in the school of hard knocks later on.
Note that most of these notes merely amplify on the things K&R is saying; there isn't much to say that it doesn't already say, usually better. In particular, many of the things that I'll comment on in the early chapters are discussed in more detail in the later chapters; by barging in with my know-it-all comments, I'm partially destroying the authors' careful progression from an initial, slightly superficial overview to a more detailed, complete presentation. If these notes present more detail than you want to see at first, don't worry (but please do let me know); just come back to them later to see if they clear up anything you're still uncertain on. (Also, if you find the description in K&R adequately clear, you don't have to read all of these notes, but do take note of the highlighted ``deep sentences.'')
Uses
C is often used for "system programming", including implementing operating systems and embedded system applications, due to a combination of desirable characteristics such as code portability and efficiency, ability to access specific hardware addresses, ability to pun types to match externally imposed data access requirements, and low run-time demand on system resources. C can also be used for website programming using CGI as a "gateway" for information between the Web application, the server, and the browser.[11] Some reasons for choosing C over interpreted languages are its speed, stability, and near-universal availability.[12]
One consequence of C's wide availability and efficiency is that compilers, libraries, and interpreters of other programming languages are often implemented in C. The primary implementations of Python (CPython), Perl 5, and PHP are all written in C.
Due to its thin layer of abstraction and low overhead, C allows efficient implementations of algorithms and data structures, which is useful for programs that perform a lot of computations. For example, the GNU Multi-Precision Library, the GNU Scientific Library, Mathematica andMATLAB are completely or partially written in C.
C is sometimes used as an intermediate language by implementations of other languages. This approach may be used for portability or convenience; by using C as an intermediate language, it is not necessary to develop machine-specific code generators. Some languages and compilers which have used C this way are BitC, C++, COBOL, Eiffel, Gambit, GHC, Modula-3, Squeak, and Vala.[13] However, C was designed as a programming language, not as a compiler target language, and is thus less than ideal for use as an intermediate language. This has led to development of C-based intermediate languages such as C--.
C has also been widely used to implement end-user applications, but much of that development has shifted to newer languages.
C (pronounced as "see", like the letter C) is a general-purpose computer programming languagedeveloped between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system.[4]
Although C was designed for implementing system software,[5] it is also widely used for developing portable application software.
C is one of the most widely used programming languages of all time[6][7] and there are very fewcomputer architectures for which a C compiler does not exist. C has greatly influenced many other popular programming languages, most notably C++, which began as an extension to C.
marks. The string may be a combination of all kinds of symbols.
No comments:
Post a Comment