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 (源链)。感谢您的支持!

您可能感兴趣的

Build 2018大会:C#的未来 看新闻很累?看技术新闻更累?试试 下载InfoQ手机客户端 ,每天上下班路上听新闻,有趣还有料! 在C#的未来特性清单上,排在第一位的是...
C语言/C++编程基础入门学习—循环结构 C语言是面向过程的,而C++是面向对象的 C和C++的区别: C是一个结构化语言,它的重点在于算法和数据结构。C程序的设计首要考虑的是如何通过一个过程,...
Jewelbots: A smart friendship bracelet that wants ... Typically handmade, friendship bracelets are shared between pals. Take one off,...
Signed Integers Are Two’s Complement Integer types allows three representations for signed integral types: ...
C++11 及之上的一些新东西 读代码的时候遇到了一些新东西,以前从没见过的语句和使用方式,惊觉 C++ 标准都扩展到 C++17 了,然而我以前写 ACM 的时候甚至连 STL 都很少用。 ...