masterminds of programming 翻译 (一)

最近在看《masterminds of programming》,觉得写的很不错。自己偏C++方向,所以想把C++这部分翻译出来,一来兴趣,二来记录自己所学。这本书现已有译本,叫做《编程之魂》。本人才疏学浅,欢迎大家批评指正(不论是计算机方面还是英语方面)。

 特别需要说明一下:这个翻译纯粹是学习交流之用,没有任何商业企图,欢迎转载分享,注明出处即可。

 

---------------------------------------------------------------------------------

Why did you choose to extend an existing language instead of creating a new one?

你为什么选择在已有的一门语言上进行扩展而不是重新建立一门新的语言?

 

Bjarne Stroustrup: When I started—in 1979—my purpose was to help

programmersbuild systems. It still is. To provide genuine help in solving a problem, rather than being just an academic exercise, a language must be complete for the application domain. That is, a non-research language exists to solve a problem. The problems I was addressing related to operating system design, networking, and simulation. I—and my colleagues— needed a language that could express program organization as could be done in Simula  (that’s what people tend to call object-oriented programming), but also write efficient low-level code, as could be done in C. No language that could do both existed in 1979, or I would have used it. I didn’t particularly want to design a new programming language; I just wanted to help solve a few problems.

在我开始(译者注:准备做这件事),也就是在1979年,我的目的是帮助程序员构建系统。这个目的至今未变。为了对解决一个实际问题提供帮助而不是仅仅停留在学术尝试层面,这个语言对于整个应用领域来说必须是完备的。也就是说,需要一个非研究性质的语言去解决问题。我说的这个问题和系统设计、网络、模拟这些问题有关。我和我的同事不仅需要该语言可以像Simula那样组织程序(就是现在人们趋于说的面向对象编程),也需要它像C语言那样写出有效的底层代码。在1979年,没有哪种语言可以同时做这两件事或者是我没发现。我当时并不特别地想要设计一门新的语言,我只是想要帮助解决一些问题。

 

Given that, building on an existing language makes a lot of sense. From the base language, you get a basic syntactic and semantic structure, you get useful libraries, and you become part of a culture. Had I not built on C, I would have based C++ on some other language. Why C? I had Dennis Ritchie, Brian Kernighan, and other Unix greats just down (or across) the hall from me in Bell Labs’ Computer Science Research Center, so the question may seem redundant. But it was a question I took seriously.

鉴于此,在一门已有语言的基础之上建立(译者注:新的语言)就很有意义了。从基础语言那里,你获得了语法和语义结构,有用的库,你也融入了该语言的部分文化。如果没有建立在C之上,我本可以将C++建立在别的语言之上。为什么是C呢?在贝尔实验室计算机科学研究中心,我有Dennis Ritchie, Brian Kernighan和其他Unix大神们围绕左右,所以这个问题显得很多余。但这是一个我认真考虑过问题。

 

In particular, C’s type system was informal and weakly enforced (as Dennis Ritchie said, “C is a strongly typed, weakly checked language”). The “weakly checked” part worried me and causes problems for C++ programmers to this day. Also, C wasn’t the widely used language it is today. Basing C++ on C was an expression of faith in the model of computation that underlies C (the “strongly typed” part) and an expression of trust in my colleagues. The choice was made based on knowledge of most higher-level programming languages used for systems programming at the time (both as a user and as an implementer). It is worth remembering that this was a time when most work “close to the hardware” and requiring serious performance was still done in assembler. Unix was a major breakthrough in many ways, including its use of C for even the most demanding systems programming tasks. So, I chose C’s basic model of the machine over better-checked type systems. What I really wanted as the framework for programs was Simula’s classes, so I mapped those into the C model of memory and computation. The result was something that was extremely expressive and flexible, yet ran at a speed that challenged assembler without a massive runtime support system.

 

特别要说一下,C的类型系统是不太正式且弱强制的(正如Dennis Ritchie所说,“C是一门强类型,弱检查的语言”)弱检查这个部分令我担忧,如今也对C++程序员带来麻烦。另外,C过去并没有像现在那样被广泛使用。将C++建立在C之上是我对C所使用的计算模型(强类型部分)的信任和对我大神同事信任的一种表达。这个选择基于对当时大多数用于系统开发的高级语言所掌握的知识。别忘了,那是一个多数离硬件很近、真正需要良好的性能表现的工作都还是用汇编语言来写的时代。Unix是在很多方面是一个重要的突破,包括它在很多系统编程任务上使用C。所以我选择C的基本机器模型并配以更好的类型检查系统。我真正想要的程序框架是像Simula的类那样的,所以我把这部分映射到C中的内存和计算模型中。结果设计出了这样一个东西:它极具表达性与灵活性,同时在没有大量使用运行时的支持系统情况下,语言执行速度接近汇编。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值