2005年当時、私はコードのほとんどがC++で書かれている会社で働いていました。2006年、経営陣は新規プロジェクトをC#で開発し、一部のC++プロジェクトもC#へ移行することを決定しました。C++に反対する彼らの主張は次のようなものでした:
- C++は複雑すぎる。
- C++のビルドシステムは管理・保守が難しすぎる。
- C++は長年停滞しており、消えゆく道をたどっている。
- C++開発者の採用が非常に難しくなっている。
そしてもちろん、ウェブ上の他の多くの意見も、管理者がC++開発を続けることを思いとどまらせました。
More important than security is the fact that C and C++ are simply too hard to program, compared to any safe language. Not only is it too easy to write a catastrophic bug in C/C++, it is even easier to write more ordinary bugs. And these bugs are very often not caught by the compiler; they are discovered months or years later, in production, often after the programmer who wrote them has moved on.As a multi-paradigm system programming language, C++ is a complete beast when it comes to its feature-set and its specs, followed up with a steep learning curve and a very long path to mastery. It’s challenging to keep track of all its complex syntactical constructs that more often than not seem confusing and ambiguous.C++ does not have a proper module system that most modern languages provide. D, Java, C#, Python, Clojure, you name it. All of them got one. In combination with its primitive preprocessor, this usually results in a messy structure of header files and implementation files that rely on include guards to give basic protection against multiple inclusion.
当時、C++開発者だった私たちには、C++を捨てないよう彼らを説得するだけの強い主張があまりありませんでした。特にMicrosoftはC++よりも.NETを推進しており、.NETテクノロジーが大きな話題になっていたからです。
現在は2018年であり、C++言語には多くの変更が加えられました。ここで問いたいのは、もしあなたの会社がC++から離れることを決めたら、C++を使い続けるよう管理者を説得するために、どのような主張ができるでしょうか?
まず重要なのは、今ではすべてが順調で、C++が弱点をすべて克服したかのように装うことは誤りだという点です。「C++はエキスパート向けになりすぎた」という認識を変えたいのであれば、改善すべき点はまだ多くあります。
幸い、C++をより使いやすくすることはC++委員会の目標の1つです。Herb Sutterは最近のインタビューで次のように説明しています:
Since mid-2015 in particular, I decided to focus my work on seeing if I could find ways to make C++ プログラム simpler. Because C++ has a long-term future, anything we can do to make C++ programs easier to write, read, and maintain will deliver big benefits to the whole industry.
The way I went about it was by systematically looking at C++ code and seeing where all the boilerplate is – that is, find the things that C++ programmers already do all the time, but that they are forced to express indirectly with excessive ceremony or in complex and brittle ways, and see if we can find a very small number of general mechanisms that could let them express those things in a simpler and more direct and robust way. If we can find the places where we regularly have to fight the language (such as the language’s defaults) or work around the language (such as by using macros or proprietary language extensions) or just rely on English advice (Scott Meyers’ books are great, but wouldn’t it be great if we didn’t need to say 75% of what’s in them), and in those places be able to directly state what we want, that would be actively improving those things that we are doing already.
A “small” historical example is the range-based for loop: We could already write for loops that visit each element, but it took more ceremony such as writing the incrementing logic by hand, and it had more ways to go wrong such as inadvertently incrementing the index or iterator in the body of the loop and skipping elements. By having a ranged-based for in the language, we elevated that very common coding pattern into a language feature that lets us now say directly what we want to do, namely visit each element in order, and that is obviously correct by construction just by looking at the first line of the loop without looking inside the body to see if it might skip elements or something. And I think the range-based for loop, though a “small” feature, was one of the major successes of C++11 – an improvement that people now use every day. Adding it to the language made the language (slightly) bigger, but it made C++ programs simpler.
- C++を支持する最初の主張は、2011年以降、言語を改善する多くの機能が追加され、さらに使いやすくするための機能が今後も追加される予定だということです。より説得力を持たせるには、現代的なC++ライブラリやプロジェクトのコードスニペットをいくつか示すのがよいでしょう。

- C++は消えゆく道をたどってはいません。多くのプログラミング言語ランキング指標が、C++が進歩していることを示しています。

- C++は開発者フォーラムでも依然として非常に活発です。Stack Overflowを見れば、毎日多くのC++に関する質問が投稿されていることが分かります。

- C++は新規プロジェクト開発でも広く使われています。これは、GitHubの言語トレンドに関するこの興味深い 記事 で紹介されているGitHubランキングが示すとおりです。

- C++コミュニティは拡大しています。Google+、LinkedIn、Facebook、Twitterを見れば、C++に関心を持つユーザーがますます増えていることが分かります。
要約すると、C++が復活し、以前よりも強力になったという事実は単なる主観的な意見ではありません。統計がそれを物語っています。今日、既存のC++コードを維持することを支持する主張は数多くあります。多くの場合、決定権は開発者にありませんが、開発者はそれぞれの状況に最も合った主張を見つけ、それを使ってC++を主要なプログラミング言語として維持するよう管理者を説得できます。
