mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
Merge pull request #25317 from lkxed/20220415-How-the-C-programming-language-has-grown
[提交译文][talk]: 20220415 How the C programming language has grown.md
This commit is contained in:
commit
04288bb076
@ -1,88 +0,0 @@
|
||||
[#]: subject: "How the C programming language has grown"
|
||||
[#]: via: "https://opensource.com/article/22/3/how-c-programming-language-has-grown"
|
||||
[#]: author: "Jim Hall https://opensource.com/users/jim-hall"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "lkxed"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
How the C programming language has grown
|
||||
======
|
||||
Here's my interview with Brian Kernighan, co-author (with Dennis Ritchie) of The C Programming Language book, to discuss the C programming language and its 50-year history.
|
||||
|
||||
![The original C programming guide by two of the language authors, circa 1978][1]
|
||||
|
||||
The C programming language will turn fifty years old in 2022. Yet despite its long history, C remains one of the top "most-used" programming languages in many "popular programming languages" surveys. For example, check out the [TIOBE Index][2], which tracks the popularity of different programming languages. Many Linux applications are written in C, such as the GNOME desktop.
|
||||
|
||||
I interviewed [Brian Kernighan][3], co-author (with Dennis Ritchie) of *The C Programming Language* book, to learn more about the C programming language and its history.
|
||||
|
||||
**Where did the C programming language come from?**
|
||||
|
||||
C is an evolution of a sequence of languages intended for system programming—that is, writing programs like compilers, assemblers, editors, and ultimately operating systems. The Multics project at MIT, with Bell Labs as a partner, planned to write everything in a high-level language (a new idea at the time, roughly 1965). They were going to use IBM's PL/1, but it was very complicated, and the promised compilers didn't arrive in time.
|
||||
|
||||
After a brief flirtation with a subset called EPL (by Doug McIlroy of Bell Labs), Multics turned to BCPL, a much simpler and cleaner language designed and implemented by Martin Richards of Cambridge, who I think was visiting MIT at the time. When Ken Thompson started working on what became Unix, he created an even simpler language, based on BCPL, that he called B. He implemented it for the PDP-7 used for the first proto-Unix system in 1969.
|
||||
|
||||
BCPL and B were both "typeless" languages; that is, they had only one data type, integer. The DEC PDP-11, which arrived on the scene in about 1971 and was the computer for the first real Unix implementation, supported several data types, notably 8-bit bytes as well as 16-bit integers. For that, a language that also supported several data types was a better fit. That's the origin of C.
|
||||
|
||||
**How was C used within Bell Labs and the early versions of Unix?**
|
||||
|
||||
C was originally used only on Unix, though after a while, there were also C compilers for other machines and operating systems. Mostly it was used for system-programming applications, which covered quite a spectrum of interesting areas, along with a lot of systems for managing operations of AT&T's telephone network.
|
||||
|
||||
**What was the most interesting project written in C at Bell Labs?**
|
||||
|
||||
Arguably, the most interesting, memorable, and important C program was the Unix operating system itself. The first version of Unix in 1971 was in PDP-11 assembly language, but by the time of the fourth edition, around 1973, it was rewritten in C. That was truly crucial since it meant that the operating system (and all its supporting software) could be ported to a different kind of computer basically by recompiling everything. Not quite that simple in practice, but not far off.
|
||||
|
||||
**You co-authored The C Programming Language book with Dennis Ritchie. How did that book come about, and how did you and Dennis collaborate on the book?**
|
||||
|
||||
I had written a tutorial on Ken Thompson's B language to help people get started with it. I upgraded that to a tutorial on C when it became available. And after a while, I twisted Dennis's arm to write a C book with me. Basically, I wrote most of the tutorial material, except for the system call chapter, and Dennis had already written the reference manual, which was excellent. Then we worked back and forth to smooth out the tutorial parts; the reference manual stayed pretty much the same since it was so well done from the beginning. The book was formatted with the *troff* formatter, one of many tools on Unix, and I did most of the formatting work.
|
||||
|
||||
**When did C become a thing that other programmers outside of Bell Labs used for their work?**
|
||||
|
||||
I don't really remember well at this point, but I think C mostly followed along with Unix for the first half dozen years or so. With the development of compilers for other operating systems, it began to spread to other systems besides Unix. I don't recall when we realized that C and Unix were having a real effect, but it must have been in the mid to late 1970s.
|
||||
|
||||
**Why did C become such an influential programming language?**
|
||||
|
||||
The primary reason in the early days was its association with Unix, which spread rapidly. If you used Unix, you wrote in C. Later on, C spread to computers that might not necessarily run Unix, though many did because of the portable C compiler that Steve Johnson wrote. The workstation market, with companies like Sun Microsystems, MIPS (which became SGI), and others, was enabled by the combination of Unix and C. The IBM PC came somewhat later, about 1982, and C became one of the standard languages, under MS-DOS and then Windows. And today, most Internet of Things (IoT) devices will use C.
|
||||
|
||||
**C remains a popular programming language today, some 50 years after its creation. Why has C remained so popular?**
|
||||
|
||||
I think C hit a sweet spot with efficiency and expressiveness. In earlier times, efficiency really mattered since computers were slow and had limited memory compared to what we are used to today. C was very efficient, in the sense that it could be compiled into efficient machine code, and it was simple enough that it was easy to see how to compile it. At the same time, it was very expressive, easy to write, and compact. No other language has hit that kind of spot quite so well, at least in my humble but correct opinion.
|
||||
|
||||
**How has the C programming language grown or changed over the years?**
|
||||
|
||||
C has grown modestly, I guess, but I haven't paid much attention to the evolving C standards. There are enough changes that code written in the 1980s needs a bit of work before it will compile, but it's mostly related to being honest about types. Newer features like complex numbers are perhaps useful, but not to me, so I can't make an informed comment.
|
||||
|
||||
**What programming problems can be solved most easily in C?**
|
||||
|
||||
Well, it's a good language for anything, but today, with lots of memory and processing power, most programmers are well served by languages like Python that take care of memory management and other more high-level constructs. C remains a good choice for lower levels where squeezing cycles and bytes still matter.
|
||||
|
||||
**C has influenced other programming languages, including C++, Java, Go, and Rust. What are your thoughts on these other programming languages?**
|
||||
|
||||
Almost every language is in some ways a reaction to its predecessors. To over-simplify a fair amount, C++ adds mechanisms to control access to information, so it's better than C for really large programs. [Java][4] is a reaction to the perceived complexity of C++. Go is a reaction to the complexity of C++ and the restrictions of [Java][4]. [Rust][5] is an attempt to deal with memory management issues in C (and presumably C++) while coming close to C's efficiency.
|
||||
|
||||
They all have real positive attributes, but somehow no one is ever quite satisfied, so there will always be more languages that, in their turn, react to what has gone before. At the same time, the older languages, for the most part, will remain around because they do their job well, and there's an embedded base where they are perfectly fine, and it would be infeasible to reimplement in something newer.
|
||||
|
||||
Thanks to Brian for sharing this great history of the C programming language!
|
||||
|
||||
Would you like to learn C programming? Start with these popular C programming articles from the last year: [5 ways to learn the C programming language in 2022][6].
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/22/3/how-c-programming-language-has-grown
|
||||
|
||||
作者:[Jim Hall][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/jim-hall
|
||||
[b]: https://github.com/lkxed
|
||||
[1]: https://opensource.com/sites/default/files/uploads/2482009942_6caea217e0_c.jpg
|
||||
[2]: https://www.tiobe.com/tiobe-index/
|
||||
[3]: https://opensource.com/article/22/1/interview-brian-kernighan
|
||||
[4]: https://opensource.com/tags/java
|
||||
[5]: https://opensource.com/tags/rust
|
||||
[6]: https://opensource.com/article/22/1/c-programming
|
@ -0,0 +1,88 @@
|
||||
[#]: subject: "How the C programming language has grown"
|
||||
[#]: via: "https://opensource.com/article/22/3/how-c-programming-language-has-grown"
|
||||
[#]: author: "Jim Hall https://opensource.com/users/jim-hall"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "lkxed"
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
C 语言发展简史
|
||||
======
|
||||
下面是我对 Brian Kernighan 的采访,他是《C 程序设计语言》一书的共同作者(与 Dennis Ritchie),我们讨论了 C 语言和它 50 年的历史。
|
||||
|
||||
![两位作者写的最初的 C 语言编程指南,大约是在 1978 年][1]
|
||||
|
||||
C 语言将在 2022 年满 50 岁。然而,尽管它历史悠久,在许多“流行编程语言”的调查中,C 语言仍然是“最常用”的编程语言之一。例如,你可以看看 [TIOBE 指数][2],它追踪不同编程语言的流行程度。许多 Linux 应用程序是用 C 语言编写的,例如 GNOME 桌面。
|
||||
|
||||
我采访了 [Brian Kernighan][3],他是 *The C Programming Language* 一书的共同作者(与 Dennis Ritchie),以了解更多关于 C 语言及其历史。
|
||||
|
||||
**C 语言是怎么诞生的呢?**
|
||||
|
||||
C 语言由一系列旨在进行系统编程的语言演变而来,系统编程就是编写像编译器、汇编器、编辑器以及最终的操作系统这样的程序。麻省理工学院有一个 Multics 项目,它以贝尔实验室为合作伙伴,计划用一种高级语言编写一切(在当时是一个新的想法,大约是 1965 年)。他们打算使用 IBM 的 PL/1,但它非常复杂,而且承诺的编译器也没有及时交付。
|
||||
|
||||
在与一个叫做 EPL 的子集(由贝尔实验室的 Doug McIlroy 设计)进行了短暂交流后,Multics 转向了 BCPL,一个由剑桥的 Martin Richards 设计和实现的,更加简单和干净的语言,我想他当时正在麻省理工学院访问。当 Ken Thompson 开始研究后来的 Unix 时,他在 BCPL 的基础上创造了一种更简单的语言,他称之为 B 语言。在 1969 年,他为 PDP-7 计算机实现了这种语言,后者搭载了第一个 Unix 原型系统。
|
||||
|
||||
BCPL 和 B 都是“无类型”语言。也就是说,它们只有一种数据类型,即整数。DEC 公司的 PDP-11 计算机大约在 1971 年投入使用,它搭载了第一个真正的 Unix 系统。PDP-11 支持几种数据类型,特别是 8 位字节和 16 位整数。因此,一种同样支持几种数据类型的语言是更好的选择。这就是 C 语言的起源。
|
||||
|
||||
**C 语言在贝尔实验室和早期版本的 Unix 中是如何使用的呢?**
|
||||
|
||||
C 语言最初只在 Unix 上使用,尽管过了一段时间,也有了用于其他机器和操作系统的 C 语言编译器。大多数情况下,它被用于系统级的编程,涵盖了相当多有趣的领域,还有很多用于管理 AT&T 电话网络运营的系统。
|
||||
|
||||
**在贝尔实验室用 C 语言编写的最有趣的项目是什么?**
|
||||
|
||||
可以说,最有趣、最令人难忘、也是最重要的 C 语言程序就是 Unix 操作系统本身。1971 年 Unix 的第一个版本是用 PDP-11 汇编语言编写的,但到了第四版,也就是 1973 年左右,我们用 C 语言重写了它。这很关键,因为这意味着操作系统(和它所有的支持软件)基本上可以通过重新编译来移植到不同类型的计算机上。虽然在实践中并没有那么简单,但也差不了多少。
|
||||
|
||||
**你与 Dennis Ritchie 合著了《C 程序设计语言》一书。那本书是怎么来的,你和丹尼斯又是如何在书中合作的呢?**
|
||||
|
||||
我曾经写过一本有关 B 语言(Ken Thompson 发明)的教程,帮助人们快速上手使用它。当 C 语言可用时,我将其升级为 C 语言的教程。过了一段时间,我说服了 Dennis,让他和我一起写一本 C 语言书。基本上,除了系统调用那章外,大部分的教程材料都是我写的,而 Dennis 写好了参考手册,那是非常好的。然后我们反复修改,使教程部分更加流畅。参考手册几乎没有什么变化,因为它从一开始就写得很好。这本书的格式是用 *troff* 格式器制定的,这是 Unix 上的许多工具之一,我做了大部分的格式化工作。
|
||||
|
||||
**C 语言什么时候成为了贝尔实验室以外的其他程序员用于工作的东西呢?**
|
||||
|
||||
我现在已经记不大清了,但我认为在最初的六七年里,C 语言主要是跟着 Unix 一起发展的。随着其他操作系统的编译器的发展,它开始蔓延到 Unix 以外的其他系统。我不记得我们是什么时候意识到 C 和 Unix 产生了真正的影响,但一定是在 20 世纪 70 年代中期到后期。
|
||||
|
||||
**为什么 C 语言会成为如此有影响力的编程语言呢?**
|
||||
|
||||
早期的主要原因是它与 Unix 的联系,Unix 在世界上迅速传播。如果你使用 Unix,你就会用 C 语言来编程。后来,C 语言传播到不一定运行 Unix 的计算机上,很大程度上是因为 Steve Johnson 编写了可移植 C 语言编译器。在工作站领域,比如 Sun Microsystems、MIPS(后来成为 SGI)和其他公司,它们都是因为 Unix 和 C 语言的结合而获得成功。IBM PC 出现得稍晚一些,大约在 1982 年。后来 C 语言成为 MS-DOS 和 Windows 下的标准编程语言之一。今天,大多数物联网(IoT)设备将使用 C 语言。
|
||||
|
||||
**在创建约 50 年后的今天,C 仍然是一种流行的编程语言。为什么它仍然如此受欢迎呢?**
|
||||
|
||||
我认为 C 语言在效率和表现力这两个方面达到了一个平衡点。在早期,效率真的很重要,因为当时的计算机速度很慢,而且与我们今天所习惯的计算机相比,当时的计算机内存十分有限。C 语言是非常高效的,因为它可以被编译成高效的机器代码,而且它也足够简单,人们很容易学会如何编译它。同时,它还具有很强的表现力,易于编写,并且结构紧凑。至少在我谦虚而正确的观点中,没有任何一种语言能很好地达到这种境界。
|
||||
|
||||
**多年来,C 语言的发展和变化如何?**
|
||||
|
||||
我想,C 语言的发展是适度的,但我并没有太注意 C 语言标准的发展。C 语言已经有足够的改变了,80 年代写的代码需要做一些预备工作才能编译,但这主要与对类型的诚实有关。比较新的功能,如复数,也许是有用的,但我不用它们,所以我不能做出明智的评论。
|
||||
|
||||
**哪些编程问题可以用C语言最容易解决?**
|
||||
|
||||
嗯,对于任何事情来说,它都是一种很好的语言,但在今天,有了充足的内存和处理能力,大多数程序员都可以用 Python 这样的语言来进行内存管理和处理其他更高级的结构。C 语言仍然是底层编程的一个很好的选择,因为对于底层编程来说,充分利用 CPU 周期和每一个字节仍然很重要。
|
||||
|
||||
**C 语言影响了其他编程语言,包括 C++、Java、Go 和 Rust。你对这些编程语言有什么看法?**
|
||||
|
||||
几乎每一种语言在某些方面都是对其前辈的反应。简单点说,C++ 增加了控制信息访问的机制,所以对于真正的大型程序来说,它比 C 更好。[Java][4] 是对 C++ 的复杂性的一种反应。Go 是对 C++ 的复杂性和 [Java][4] 的限制的一种反应。[Rust][5] 是对 C 语言(大概也是对 C++)中内存管理问题的一种尝试,同时它接近了 C 语言的效率。
|
||||
|
||||
它们都带来了某些积极的特性,但不知何故,没有人能够完全满意,所以总是会有更多的语言,反过来对以前的语言做出反应。同时,老的语言,在大多数情况下,会继续存在,因为它们的工作做得很好,而且有一个嵌入式的基础,老的语言在里面可以完美使用,而用新的东西来重新实现是不可行的。
|
||||
|
||||
感谢 Brian 为我们分享了 C 语言编程的伟大历史!
|
||||
|
||||
你想学习 C 语言编程吗?从去年的这些流行的C语言编程文章开始吧:[2022 年学习 C 语言的 5 种方法][6]。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/22/3/how-c-programming-language-has-grown
|
||||
|
||||
作者:[Jim Hall][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[lkxed](https://github.com/lkxed)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/jim-hall
|
||||
[b]: https://github.com/lkxed
|
||||
[1]: https://opensource.com/sites/default/files/uploads/2482009942_6caea217e0_c.jpg
|
||||
[2]: https://www.tiobe.com/tiobe-index/
|
||||
[3]: https://opensource.com/article/22/1/interview-brian-kernighan
|
||||
[4]: https://opensource.com/tags/java
|
||||
[5]: https://opensource.com/tags/rust
|
||||
[6]: https://opensource.com/article/22/1/c-programming
|
Loading…
Reference in New Issue
Block a user