Why C++ succeeds (为啥C++能成功)(1)
Part of the reason C++ has been so successful is that the goal was
现在C++之所以成功,其中不少原因是因为整个C++语言的设计不仅仅是将C
not just to turn C into an OOP language (although it started that
转为一种面向对象的编程语言(尽管它是以此为起点的)
way), but also to solve many other problems facing developers
更重要的是可以解决现在困扰众多程序员的问题,
today, especially those who have large investments in C.
对好些对C语言已投入很多的程序员来说更是如此。
Traditionally, OOP languages have suffered from the attitude that
以往,要是你想另学一门面向对象的编程语言的话,你必须得舍弃你所学的一切
you should abandon everything you know and start from scratch
而以一套全新的概念与理念从头开始,毕竟那个新的OOP从长远来的看,以它
with a new set of concepts and a new syntax, arguing that it's better
比过程式编程语言强的多优势在吸引着我们。
in the long run to lose all the old baggage that comes with
procedural languages. This may be true, in the long run. But in the
是的,不错,从长远来说,这种转化是划算的。
short run, a lot of that baggage was valuable. The most valuable
不过,近期来看,过程式语言的累赘还是很有价值的。
elements may not be the existing code base (which, given adequate
这种过程式语言中最为有价值的不是它现有的代码基础(这些代码基础,在一定条件下是可能转化的)
tools, could be translated), but instead the existing
而是现有的思维基础。
mind base. If you're a functioning C programmer and must drop everything you
比如说,你是一个用C语言来工作的程序员,工作过程中要另学一门新的语言,你必须丢下现有关于C
know about C in order to adopt a new language, you immediately
的知识从头开始,这样数月期间内直到你思维转化成功你的生产效率将大大降低。
become much less productive for many months, until your mind
fits around the new paradigm. Whereas if you can leverage off of
然而,要是你能在现在对C语言掌握的基础上进行扩展的话,你就可能
your existing C knowledge and expand on it, you can continue to
以现在的C语言基础保持工作效率,同时也转进面向对象编程的世界。
be productive with what you already know while moving into the
world of object-oriented programming. As everyone has his or her
由于每个人都有他或她对编程固有的思维模式,从头开始另学一门新的编程语言
own mental model of programming, this move is messy enough as
是相当混乱的。
it is without the added expense of starting with a new language
model from square one. So the reason for the success of C++, in a
所以,总的来说,现在C++取得成功的一个原因是其因与C语言的固有联系而带的
nutshell, is economic: It still costs to move to OOP, but C++ may
经济好处,不过从C转向C++仍需努力,就是这个努力相对少了些。
cost less
The goal of C++ is improved productivity. This productivity comes
从C到C++的改进是为了提高其运行效率。这种效率的提升表现在很多方面,
in many ways, but the language is designed to aid you as much as
但是设计C++的目地是尽可能帮助你同时也以多种规则来降低你的学习难度。
possible, while hindering you as little as possible with arbitrary
rules or any requirement that you use a particular set of features.
C++ is designed to be practical; C++ language design decisions
C++是从于实用的考虑而设计设计的,也正因此C++的设计决定是基于向程序员
were based on providing the maximum benefits to the programmer
(只好以C程序员的角度来看是这样的)提供尽可能多的便利而展开的
(at least, from the world view of C).