C语言程序设计 第一章C语言概述.1

1.Introducing C

What is C? The simple answer-a widely used programming language developed in the early 1970s at Bell Laboratories-conveys little of C's special flavor. Beforewe become immersed in the details of the language, let's take a look at where C came from, what it was designed for, and how it has changed over the years (Sec-tion I.l). We'II also discuss C's strengths and weaknesses and see how to get themost out of the language (Section l.2).

什么是C语言?它是20世纪70年代初期在贝尔实验室开发出来的一种用途广泛的编程语言。这种简单回答传递出少许c语言特有的风味。在深入学习这门语言之前,让我们先来回顾一下c语言的起源,c语言的设计目标,以及其后续的转变历程(I.1节)。我们还将讨论C语言的优缺点,并且了解一下如何最佳地使用C语言(1.2节)


1.1   History of C

Let's take a quick look at C's history from its origins, to its coming of age as a standardized language. to its influence on recent languages.

C语言的历史可以追溯到计算机领域的“古生代”时期,即20世纪60年代末期。让我们对C语言发展史作一简单回顾,从它在贝尔实验室的起源开始,再到它作为一种标准化语言的时代,最后谈到它对近代编程语言的影响。


Origins

C is a by-product of the UNIX operating system, which was developed at Bell Lab-oratories by Ken Thompson, Dennis Ritchie. and others. Thompson single-hand-edly wrote the original version of' UNIX. which ran on the DEC PDP-7 computer.an early minicomputer with only 8K word,s of main memory (this was 1969. after all!)

C语言是在贝尔实验室由Ken Thompson、Dennis Ritchie及其他同事在开发UNIX操作系统的过程中的副产品。Thompson独自动手编写了UNIX操作系统的最初版本,这套系统运行在DEC PDP-7计算机上。这款早期的小型计算机仅有16K字节内存(毕竟那是在1969年!)


Like other operating systems of the time. UNIX was written in assembly lan-guage. Programs written in assembly language are usually painful to debug and hard to enhance: UNIX was no exception. Thompson decided that a higher-level language was needed for the further development of UNIX. so he designed a small language named B. Thompson based B on BCPL. a systems programming language developed in the mid-1960s. BCPL, in turn. traces its ancestry to Algol 6().one of the earliest (and most influential) programming languages.

与同时代的其他操作系统一样,UNIX系统最初也是用汇编语言编写的。用汇编语言缟写的程序往往难以调试和改进,UNx系统也不例外。Thompson意识到需要用一种更加高级的编程[口语言来完成UNIX系统未来的开发,于是他设计了一种小型的B语言。Thompson的B语言是在BCPL语言的基础上开发的(BCPL语言是20世纪60年代中期产生的一种系统编程语言),圆墨I而BCPL语言的起源又可以追溯到一种最早的(并且影响最深远的)Algol 60语言。


Ritchie soon joined the UNIX project and began programming in B. In L970.Bell Labs acquired a PDP-1 I for the UNIX project. Once B was up and running on the PDP-II, Thompson rewrote a portion of UNIX in B. By 1971. it became apparent that B was not wejI-suited to the PDP-II. so Ritchie began to develop an extended version of B. He called his language NB ("New B") at first, and then, as it began to diverge more from B. he changed the name to C. The language was sta-ble enough by 1973 thar UNIX could be rewriiten in C. The switch to C provided an importanL benet-it: portability. By writing C compilers for other computers at Bell Labs, the team could get UNIX running on those machines as well.

不久.Ritchie也加入到UNIX项目,并且开始着手用B语言编写程序。1 970年,贝尔实验室为UNIX项目争取到一台PDP-11计算机。当B语言经过改进并且运行在了PDP-1I计算机上时,Thompson就用B语言重新编写了部分UNIX代码。到了1971年,B语言已经暴露出非常不适台PDP-II计算机的问题,于是Ritchie开始开发B语言的升级版。他蛀初将新开发的语言命名为NB语言(意为“NewB”),但是后来,新语言越来越脱离B语言,于是他决定将它改名为C语言。到1973年,C语言已经足够稳定,可以用来重新编写UNIX系统了。改用C语言编写程序显示出一个非常重要的好处:可移植性。通过在贝尔实验室里为其他类型计算机编写C谮言编译器,UNIX系统也同样可以在不同类型的计算机上运行了。


Standardization

C continued to evolve during the 1970s. especially between I977 and 1979. It was during this period that the first book on C appeared. The C programming Language, written by Brian Kernighan and Dennis Ritchie and published in 1978.quickly became the bible of C programmers. In the absence of an official standardfor C, this book-known as K&R or the "White Book" to aficionados-served as ade facto standard.

整个20世纪70年代,特别是1977年到1979年之间,C语言一直在持续发展。这一时期出现 了第一本有关C语言的书。1978年,Brian Kemighan和Dennis Ritchie合作编写并出版了The C Programming Language-书。此书一经出版就迅速成为了C程序员的宝典。由于当时缺少C语言的正式标准,所以这本书就成为了事实上的标准,编程爱好者把它称为“K&R”或者“白皮书”。


During the 1970s, there were relatively few C programmers, and most of themwere UNIX users. By the 1980s, however. C had expanded beyond the narrow con-fines of the UNIX world. C compilers became available on a variety of machinesrunning under different operating systems. In particular. C began to establish itselfon the fast-growing IBM PC platform.

在20世纪70年代,C程序员相对较少,而且他们中的大多数人都是UNIX系统的用户。然而到了20世纪80年代,C语言已经超越了UNIX领域的界限。运行在不同操作系统下的多种类型的计算机都开始使用C语言编译器。特别是,迅速壮大的IBM PC机平台也开始使用C语言。


With C's increasing popularity came problems. Programmers who wrote new C compilers relied on K&R as a reference. Unfortunately, K&R was fuzzy about some language features. so compilers often treated these features differenrly. Also.K&R failed to make a clear distinction between which features belonged to C and which were part of UNIX. To make matters worse. C continued to change after K&R was published, with new features being added and a few older features removed. The need for a thorough, precise. and up-to-date description of the lan-guage soon became apparent. Withour such a standard. numerous dialects would have arisen. threatening the portability of C programs, one of the language's major strengths.

随着C语言的迅速普及,一系列问题也接踵而至。编写新的C语言编译器的程序员们都把 “K&R”作为参考。但是遗憾的是,“K,&R”对一些语言特性的描述非常模糊,以至于编译器常常会对这些特征进行不同的处理。而且,“K&R”也没有对属于C语言的特性和属于UNIX系统的内容进行明确的区分。何况在“K&R”出版以后,C语言仍在不断变化,增加了新特性并且去除了少量过时的特性。不久,这种对C语言进行全面、准确并且最新描述的需求开始显观出来。如果没有这样一种标准,就将会出现各种“方言”,这势必会威胁C语言的主要优势之一——程序的可移植性。


The development of a U.S. standard for C began in 1983 under the auspices of the American National Standards Institute (ANSI). After many revisions. the stan-dard was completed in 1988 and formally approved in December 1989 as ANSI standard X3.159-1989. In 1990, it was approved by the Intenational Organization for Standardization (ISO) as international standard ISO/IEC 9899:1990. This ver-sion of the language is usually referred to as C89 0r C90. to distinguish it from theoriginal version of C, often called K&R C. Appendix C summarizes the major differences between C89 and K&R C.

1983年,美国国家标准协会(ANSI)开始编制C语言标准。经过多次修订,C语言标准于1988年完成,并且在1989年12月正式通过,成为ANSI标准X3.159-1989。1990年,国际标

准化组织(ISO)通过此项标准,将其作为ISO/IEC 9899-1990国际标准①。此版本的语言通常称为C89或C90标准,与K&R这样的理论版本区分开来。


The language underwent a few changes in 1995 (described in a document known as Amendment l). More significant changes occurred with the publicaiion of a new standard, ISO/IEC 9899:1999. in 1999. The language described in chis standard is commonly known as C99. The terms "ANSI C," "ANSI/ISO C." and "ISO C"-once used to describe C89-are now ambiguous. thanks to the existenceof two standards.


Because C99 isn't yet universal, and because of the need to maintain millions(if not billions) of lines of code written in older versions of C. I'II use a special icon(shown in the Iefts margin) to mark discussions of features that were added in C99.

A compiler that doesn't recognize these features isn't "C99-compliant." If history is any guide, it will be some years before all C compilers are C99-compliant, if they ever are. Appendix B lists the major differences between C99 and C89.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值