What’s all the C Plus Fuss? Bjarne Stroustrup warns of dangerous future plans for his C++

综合编程 2018-06-18 阅读原文

InterviewEarlier this year, Bjarne Stroustrup, creator of C++, managing director in the technology division of Morgan Stanley, and a visiting professor of computer science at Columbia University in the US, wrote a letter
inviting those overseeing the evolution of the programming language to “Remember the Vasa!”

Easy for a Dane to understand no doubt, but perhaps more of a stretch for those with a few gaps in their knowledge of 17th century Scandinavian history. The Vasa was a Swedish warship, commissioned by King Gustavus Adolphus. It was the most powerful warship in the Baltic Sea from its maiden voyage on the August 10, 1628, until a few minutes later when it sank.

The formidable Vasa suffered from a design flaw: it was top-heavy, so much so that it was undone by a gust of wind
. By invoking the memory of the capsized ship, Stroustrup served up a cautionary tale about the risks facing C++ as more and more features get added to the language.

Quite a few such features have been suggested. Stroustrup cited 43 proposals in his letter. He contends those participating in the evolution of the ISO standard language, a group known as WG21
, are working to advance the language but not together.

In his letter, he wrote:

Individually, many proposals make sense. Together they are insanity to the point of endangering the future of C++.

He makes clear that he doesn’t interpret the fate of the Vasa to mean that incremental improvements spell doom. Rather, he takes it as a lesson to build a solid foundation, to learn from experience and to test thoroughly.

With the recent conclusion of the C++ Standardization Committee Meeting in Rapperswil, Switzerland, earlier this month, Stroustrup addressed a few questions put to him by The Register
about what's next for the language. (The most recent version is C++17, which arrived last year; the next version C++20 is under development and expected in 2020.)


Register:
In your note, Remember the Vasa!, you wrote:

The foundation begun in C++11 is not yet complete, and C++17 did little to make our foundation more solid, regular, and complete. Instead, it added significant surface complexity and increased the number of features people need to learn. C++ could crumble under the weight of these – mostly not quite fully-baked – proposals. We should not spend most our time creating increasingly complicated facilities for experts, such as ourselves.

Is C++ too challenging for newcomers, and if so, what features do you believe would make the language more accessible?


Stroustrup:

Some parts of C++ are too challenging for newcomers.

On the other hand, there are parts of C++ that makes it far more accessible to newcomers than C or 1990s C++. The difficulty is to get the larger community to focus on those parts and help beginners and casual C++ users to avoid the parts that are there to support implementers of advanced libraries.

I recommend the C++ Core Guidelines
as an aide for that.

Also, my “A Tour of C++” can help people get on the right track with modern C++ without getting lost in 1990s complexities or ensnarled by modern facilities meant for expert use. The second edition of “A Tour of C++” covering C++17 and parts of C++20 is on its way to the stores.

I and others have taught C++ to 1st year university students with no previous programming experience in 3 months. It can be done as long as you don’t try to dig into every obscure corner of the language and focus on modern C++.

“Making simple things simple” is a long-term goal of mine. Consider the C++11 range-for loop:

for (int& x : v) ++x; // increment each element of the container v

where v can be just about any container. In C and C-style C++, that might look like this:

for (int i=0; i<MAX; i++) ++v[i];  // increment each element of the array v

Some people complained that adding the range-for loop made C++ more complicated, and they were obviously correct because it added a feature, but it made the use
of C++ simpler. It also eliminated some common errors with the use of the traditional for loop.

Another example is the C++11 standard thread library. It is far simpler to use and less error-prone than using the POSIX or Windows thread C APIs directly.

Register:
How would you characterize the current state of the language?


Stroustrup:

C++11 was a major improvement of C++ and C++14 completed that work. C++17 added quite a few features without offering much support for novel techniques. C++20 looks like it might become a major improvement. The state of compilers and standard-library implementations are excellent and very close to the latest standards. C++17 is already usable. The tool support is improving steadily. There are lots of third-party libraries and many new tools. Unfortunately, those can be hard to find.

The worries I expressed in the Vasa paper relate to the standards process that combines over-enthusiasm for novel facilities with perfectionism that delays significant improvements. “The best is the enemy of the good.” There were 160 participants at the June Rapperswil meeting. It is hard to keep a consistent focus in a group that large and diverse. There is also a tendency for experts to design more for themselves than for the community at large.

Sponsored:
Minds Mastering Machines - Call for papers now open

The Register

责编内容by:The Register阅读原文】。感谢您的支持!

您可能感兴趣的

c++循环引用 虽然C++11引入了智能指针的,但是开发人员在与内存的斗争问题上并没有解放,如果我门实用不当仍然有内存泄漏问题,其中智能指针的循环引用缺陷是最大的问题。 我们可以看到在出main函数作用域之前两个指针指向的内存并没有释放(指针指向的对象没有调用析构函数),我门把当前的引用数打印...
(三):C++分布式实时应用框架——系统管理模块... C++分布式实时应用框架——系统管理模块 上篇: (二): 基于ZeroMQ的实时通讯平台 一个分布式实时系统集群动辄上百台机器,集群的规模已经限定这将是一个”封闭“的系统。你不可能再一台台去操作上百台机器,传统的人工运维方式早已不能满足当下需要,所有对集群或者集群中某个节点的操作都必...
C++ Guide for EOS Development – Templates This post is part of my C++ Guide for EOS developers Basics Call by value / reference & Pointers Classes and Structs Templ...
Page Objects with Partial Classes and Properties- ... Editorial Note: I originally wrote this post for the Test Huddle Blog . You can check out the original her...
分享一个加速Unity工程C#编译的方法 这个是最近一段时间带着子川一起做的一个小东西:如何优化大项目C#编译速度。这个idea主要是因为使用了slua之后,每次修改C#部分编译实在是太慢了… 下面将介绍直接介绍一个简单思路来优化之 (其他的一些失败尝试和思考我扔在了 自己博客 上,包括一键编译cs文件成dll)。 这个思路...