The C Programming Language

Last updated
The C Programming Language
The C Programming Language, First Edition Cover.svg
Cover of the first edition.
Author Brian Kernighan
Dennis Ritchie
LanguageEnglish
Subject C programming language
Publisher Prentice Hall
Publication date
1978 (1st Edition)
1988 (2nd Edition)
ISBN 9780131101630

The C Programming Language (sometimes termed K&R, after its authors' initials) is a computer programming book written by Brian Kernighan and Dennis Ritchie, the latter of whom originally designed and implemented the C programming language, as well as co-designed the Unix operating system with which development of the language was closely intertwined. The book was central to the development and popularization of C and is still widely read and used today. Because the book was co-authored by the original language designer, and because the first edition of the book served for many years as the de facto standard for the language, the book was regarded by many to be the authoritative reference on C. [1] [2]

Contents

History

C was created by Dennis Ritchie at Bell Labs in the early 1970s as an augmented version of Ken Thompson's B. [3] Another Bell Labs employee, Brian Kernighan, had written the first C tutorial, [4] and he persuaded Ritchie to coauthor a book on the language. [5] Kernighan would write most of the book's "expository" material, and Ritchie's reference manual became its appendices.

The first edition, published February 22, 1978, was the first widely available book on the C programming language. Its version of C is sometimes termed K&R C (after the book's authors), often to distinguish this early version from the later version of C standardized as ANSI C . [6]

In April 1988, the second edition of the book was published, updated to cover the changes to the language resulting from the then-new ANSI C standard, particularly with the inclusion of reference material on standard libraries. The second edition of the book (and as of 2024, the most recent) has since been translated into over 20 languages. [7] In 2012, an eBook version of the second edition was published in ePub, Mobi, and PDF formats. [8]

C was first standardized in 1989 (as ANSI X3.159-1989) and has since undergone several revisions. However, no new edition of The C Programming Language has been issued to cover the more recent standards.

Reception

Byte magazine stated in August 1983, "[The C Programming Language] is the definitive work on the C language. Don't read any further until you have this book!" [1] Jerry Pournelle wrote in the magazine that year that the book "is still the standard ... a bit terse". He continued, "You can learn the C language without getting Kernighan and Ritchie, but that's doing it the hard way. You're also working too hard if you make it the only book on C that you buy." [9]

Influence

The C Programming Language has often been cited as a model for technical writing, with reviewers describing it as having clear presentation and concise treatment. Examples generally consist of complete programs of the type one is likely to encounter in daily use of the language, with an emphasis on system programming. Its authors said

We have tried to retain the brevity of the first edition. C is not a big language, and it is not well served by a big book. We have improved the exposition of critical features, such as pointers, that are central to C programming. We have refined the original examples, and have added new examples in several chapters. For instance, the treatment of complicated declarations is augmented by programs that convert declarations into words and vice versa. As before, all examples have been tested directly from the text, which is in machine-readable form.

preface to the second edition [10]
"Hello, World!" program by Brian Kernighan (1978) Hello World Brian Kernighan 1974.jpg
"Hello, World!" program by Brian Kernighan (1978)

The book introduced the "Hello, World!" program, which prints only the text "hello, world", as an illustration of a minimal working C program. Since then, many texts have followed that convention for introducing a programming language.

Before the advent of ANSI C, the first edition of the text served as the de facto standard of the language for writers of C compilers. With the standardization of ANSI C, the authors more consciously wrote the second edition for programmers rather than compiler writers, saying

Appendix A, the reference manual, is not the standard, but our attempt to convey the essentials of the standard in a smaller space. It is meant for easy comprehension by programmers, but not as a definition for compiler writers—that role properly belongs to the standard itself. Appendix B is a summary of the facilities of the standard library. It too is meant for reference by programmers, not implementers. Appendix C is a concise summary of the changes from the original version.

preface to the second edition [10]

The influence of The C Programming Language on programmers, a generation of whom first worked with C in universities and industry, has led many to accept the authors' programming style and conventions as recommended practice, if not normative practice. For example, the coding and formatting style of the programs presented in both editions of the book is often referred to as "K&R style" or the "One True Brace Style" and became the coding style used by convention in the source code for the Unix and Linux kernels.

See also

Related Research Articles

ANSI C, ISO C, and Standard C are successive standards for the C programming language published by the American National Standards Institute (ANSI) and ISO/IEC JTC 1/SC 22/WG 14 of the International Organization for Standardization (ISO) and the International Electrotechnical Commission (IEC). Historically, the names referred specifically to the original and best-supported version of the standard. Software developers writing in C are encouraged to conform to the standards, as doing so helps portability between compilers.

<span class="mw-page-title-main">Brian Kernighan</span> Canadian computer scientist

Brian Wilson Kernighan is a Canadian computer scientist. He worked at Bell Labs and contributed to the development of Unix alongside Unix creators Ken Thompson and Dennis Ritchie. Kernighan's name became widely known through co-authorship of the first book on the C programming language with Dennis Ritchie. Kernighan affirmed that he had no part in the design of the C language.

B is a programming language developed at Bell Labs circa 1969 by Ken Thompson and Dennis Ritchie.

C is a general-purpose computer programming language. It was created in the 1970s by Dennis Ritchie, and remains very widely used and influential. By design, C's features cleanly reflect the capabilities of the targeted CPUs. It has found lasting use in operating systems, device drivers, and protocol stacks, but its use in application software has been decreasing. C is commonly used on computer architectures that range from the largest supercomputers to the smallest microcontrollers and embedded systems.

<span class="mw-page-title-main">Dennis Ritchie</span> American computer scientist, co-creator of the Unix operating system

Dennis MacAlistair Ritchie was an American computer scientist. He is best known for creating the C programming language and, with long-time colleague Ken Thompson, the Unix operating system and B programming language. Ritchie and Thompson were awarded the Turing Award from the ACM in 1983, the Hamming Medal from the IEEE in 1990 and the National Medal of Technology from President Bill Clinton in 1999. Ritchie was the head of Lucent Technologies System Software Research Department when he retired in 2007. He was the "R" in K&R C, and commonly known by his username dmr.

Yacc is a computer program for the Unix operating system developed by Stephen C. Johnson. It is a lookahead left-to-right rightmost derivation (LALR) parser generator, generating a LALR parser based on a formal grammar, written in a notation similar to Backus–Naur form (BNF). Yacc is supplied as a standard utility on BSD and AT&T Unix. GNU-based Linux distributions include Bison, a forward-compatible Yacc replacement.

<i>A Commentary on the UNIX Operating System</i> Book

A Commentary on the Sixth Edition UNIX Operating System by John Lions is a highly influential 1976 publication containing analytical commentary on the source code of the 6th Edition Unix computer operating system "resident nucleus" software, plus copy formatted and indexed by Lions, of said source code obtained from the authors at AT&T Bell Labs. It is also commonly referred to as the Lions Book.

<span class="mw-page-title-main">Unix philosophy</span> Software development philosophy

The Unix philosophy, originated by Ken Thompson, is a set of cultural norms and philosophical approaches to minimalist, modular software development. It is based on the experience of leading developers of the Unix operating system. Early Unix developers were important in bringing the concepts of modularity and reusability into software engineering practice, spawning a "software tools" movement. Over time, the leading developers of Unix established a set of cultural norms for developing software; these norms became as important and influential as the technology of Unix itself, and have been termed the "Unix philosophy."

The C programming language provides many standard library functions for file input and output. These functions make up the bulk of the C standard library header <stdio.h>. The functionality descends from a "portable I/O package" written by Mike Lesk at Bell Labs in the early 1970s, and officially became part of the Unix operating system in Version 7.

In computer science, primitive data types are a set of basic data types from which all other data types are constructed. Specifically it often refers to the limited set of data representations in use by a particular processor, which all compiled programs must use. Most processors support a similar set of primitive data types, although the specific representations vary. More generally, "primitive data types" may refer to the standard data types built into a programming language. Data types which are not primitive are referred to as derived or composite.

m4 is a general-purpose macro processor included in most Unix-like operating systems, and is a component of the POSIX standard.

The computer programming languages C and Pascal have similar times of origin, influences, and purposes. Both were used to design their own compilers early in their lifetimes. The original Pascal definition appeared in 1969 and a first compiler in 1970. The first version of C appeared in 1972.

<i>The Unix Programming Environment</i> Book by Brian Kernighan

The Unix Programming Environment, first published in 1984 by Prentice Hall, is a book written by Brian W. Kernighan and Rob Pike, both of Bell Labs and considered an important and early document of the Unix operating system.

<span class="mw-page-title-main">History of Unix</span>

The history of Unix dates back to the mid-1960s, when the Massachusetts Institute of Technology, AT&T Bell Labs, and General Electric were jointly developing an experimental time-sharing operating system called Multics for the GE-645 mainframe. Multics introduced many innovations, but also had many problems. Bell Labs, frustrated by the size and complexity of Multics but not its aims, slowly pulled out of the project. Their last researchers to leave Multics – among them Ken Thompson, Dennis Ritchie, Doug McIlroy, and Joe Ossanna – decided to redo the work, but on a much smaller scale.

cpio is a general file archiver utility and its associated file format. It is primarily installed on Unix-like computer operating systems. The software utility was originally intended as a tape archiving program as part of the Programmer's Workbench (PWB/UNIX), and has been a component of virtually every Unix operating system released thereafter. Its name is derived from the phrase copy in and out, in close description of the program's use of standard input and standard output in its operation.

assert.h is a header file in the C standard library. It defines the C preprocessor macro assert and implements runtime assertion in C.

<span class="mw-page-title-main">Unix</span> Family of computer operating systems

Unix is a family of multitasking, multi-user computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, and others.

<span class="mw-page-title-main">Ken Thompson</span> American computer scientist, co-creator of the Unix operating system

Kenneth Lane Thompson is an American pioneer of computer science & Computer Chess Development. Thompson worked at Bell Labs for most of his career where he designed and implemented the original Unix operating system. He also invented the B programming language, the direct predecessor to the C programming language, and was one of the creators and early developers of the Plan 9 operating system. Since 2006, Thompson has worked at Google, where he co-developed the Go programming language.

<span class="mw-page-title-main">Unix filesystem</span> Directory structure used by a Unix-like operating system

In Unix and operating systems inspired by it, the file system is considered a central component of the operating system. It was also one of the first parts of the system to be designed and implemented by Ken Thompson in the first experimental version of Unix, dated 1969.

cat (Unix) Unix command utility

cat is a standard Unix utility that reads files sequentially, writing them to standard output. The name is derived from its function to (con)catenate files . It has been ported to a number of operating systems.

References

  1. 1 2 Ward, Terry A. (August 1983). "Annotated C / A Bibliography of the C Language". Byte. p. 268. Retrieved 31 January 2015.
  2. Prinz, Peter; Crawford, Tony (2005-12-16). C in a Nutshell. O'Reilly Media, Inc. p. 3. ISBN   9780596550714.
  3. Ritchie, Dennis M. (1993). "The Development of the C Language". History of Programming Languages, 2nd Edition. Retrieved 2018-11-11.
  4. "Leap In and Try Things: Interview with Brian Kernighan". Harmony at Work. October 24, 2009. Archived from the original on July 23, 2012. Retrieved 2013-03-03.
  5. Computerphile (2015-08-18). "'C' Programming Language: Brian Kernighan - Computerphile". Archived from the original on 2021-12-21. Retrieved 2018-11-11.
  6. Kernighan, Brian W.; Ritchie, Dennis M. (February 1978). The C Programming Language (1st ed.). Englewood Cliffs, NJ: Prentice Hall. ISBN   0-13-110163-3.
  7. Keninghan, Brian W. "The C Programming Language, Second Edition". Priceton University. Retrieved 18 February 2023.
  8. Keninghan, Brian W. (1 October 2012). "An Interview with Brian Kernighan on C and The C Programming Language". InformIT (Interview). Interviewed by John Wait.
  9. Pournelle, Jerry (December 1983). "The User Looks at Books". Byte. p. 519. Retrieved 24 July 2016.
  10. 1 2 Kernighan, Brian; Ritchie, Dennis M. (March 1988). The C Programming Language (2nd ed.). Englewood Cliffs, NJ: Prentice Hall. ISBN   0-13-110362-8.
C language standards Succeeded by
C89 / C90 / "ANSI C"
(2nd edition of book)