7

I am currently updating my knowledge on C++ to the new standard. It makes me feel like a little kid that just got the awesomest toy: I want to play with it all the time but I don't want to lose my friends because of it.

I am involved in a few open source projects for which some of the new features would be extremely useful, so I am quite keen on using them. My question is how many users can compile C++11 code, e.g. what's the adoption rate of C++11-complete compilers in the general public? Does anyone have related information?

I know that gcc 4.8.1 and clang 3.3 are C++11 feature complete, but I have no idea how many people actually use compilers that are up to date. I know most codemonkeys surely do, but what about the average open source user? Slapping potential users in the face and telling them to update their compilers is not really an option.

I am aware that this question may be criticised/closed for being similar to these questions:

  1. How are you using C++11 today?
  2. To use or not to use C++0x features

I would like to point out that things are different now, since we are talking about an actual approved standard. I believe that being aware of its adoption rate is important in practice for programming.

Community
  • 1
  • 1
Marc Claesen
  • 16,778
  • 6
  • 27
  • 62
  • 3
    gcc 4.8.1 and clang 3.3 are at least available as pre-built packages on Ubuntu / Debian systems. So even if people don't currently use these compilers, it's not hard to install them (as opposed to building from source which is much trickier). For open source projects, I don't think it's a slap in the face to install an updated compiler package. – TemplateRex Aug 22 '13 at 09:26
  • well, I would say when ubuntu and friends get those compilers as default cpp compiler you are good to go. :) – NoSenseEtAl Aug 22 '13 at 09:27
  • @JesseGood my question is what the adoption rate *of those compilers* is in the user base. Maybe I phrased it wrong. Compiler documentation doesn't include the amount of users. – Marc Claesen Aug 22 '13 at 09:27
  • @NoSenseEtAl the upcoming 13.10 (October) version of Ubuntu will have 4.8.1, so will Linxu Mint 16 (November). So not very far away, and the current 4.7.3 is *almost* feature complete – TemplateRex Aug 22 '13 at 09:29
  • 1
    @MarcClaesen: Okay, I understand your question now. However, if you want to support windows users (MSVC), the adoption rate is going to be low. – Jesse Good Aug 22 '13 at 09:30
  • 1
    @JesseGood the Nuwen Distro has MinGW 4.8.1 (32-bit, no multi-threading though) – TemplateRex Aug 22 '13 at 09:31
  • 1
    @TemplateRex: Im aware of the alternatives, but in general, there will be a demand for compiling on MSVC. – Jesse Good Aug 22 '13 at 09:33
  • 1
    @JesseGood MSVC is well just bad. :) They wont have C++11 for a long time... they didnt even announce constexpr support comming soon and it is hard to implement. :) – NoSenseEtAl Aug 22 '13 at 09:33
  • 1
    I'm sure there are several C++11 features that are not included in my gcc 4.6.3, but so far I've not found anything directly missing that I can't use when applying C++0x. As with almost any (large) development work, it's introduced piecemeal. As I understand it, MSVS 2012 has a fair bit of C++11, but not all (most notably not `std::thread`, I think). Remember that the designers of the compilers are members of the committee that produce the new standard, so there is awareness of what is coming, it's not a surprise... – Mats Petersson Aug 22 '13 at 09:35
  • 6
    @Mats MSVS2012 C++11 library is complete, including `` and ``. It's the language support that's behind. – rubenvb Aug 22 '13 at 09:37
  • 1
    @rubenvb that's not true. In truth it's almost complete but marketingspeak tends to drop words like "almost". – R. Martinho Fernandes Aug 22 '13 at 10:34
  • @R.MartinhoFernandes what's missing are either C99 functions or small things that depend on language support like `constexpr` and `noexcept` etc... You'll be hardpressed to find a competing implementation on Windows, and GCC still does not have ``. – rubenvb Aug 22 '13 at 11:28
  • The title doesn't match the actual question. I think you meant to ask something other than "How standard is...". Perhaps, "How widespread is toolchain support for..." – Ben Voigt Aug 22 '13 at 15:49
  • "It makes me feel like a little kid that just got the awesomest toy" Strange. The first time I heard about it I thought that C++ was going suicidal - language was already complex enough in C++03, and extra features would mean a lot of waiting time till new tools appear, could lead to massive popularity loss. "how many users can compile C++11 code" AFAIK, situation is good on linux (clang/g++, afaik, both support it), but is bad on windows. More or less complete support should be available only via gcc 4.8.1, but it is much slower and moodier than microsoft compiler. – SigTerm Aug 22 '13 at 16:06
  • first of your assumptions about clang being feature complete are only true for "mac os x" as that is their premiere platform. clang++ compiler is feature complete on linux as well, but libcxx (or ++), their std library is crippled on Linux, with no maintainers, the last message about clang std lib on linux is pre-3.2 days (+ error message lists), so good luck with any traction on that. as per gcc-4.8.1 again compiler is fully complaint, but stdlib is exteremly lacking, It would be atleast gcc 4.9(2014) (see status page) to make stdlib complaint, might as well slip to gcc 4.10(2015). – fedvasu Aug 26 '13 at 11:40

2 Answers2

6

You should probably first decide which C++11 you absolutely want to be able to use, and then lookup the lowest compiler version that supports this on the platforms that you want to support. Apache has a nice survey of the earliest version of each major compiler (gcc, clang, visual c++, intel, etc.) that supported the various C++11 features.

In my experience, gcc 4.7 and Clang 3.2 are almost feature complete (except for things like inheriting constructors, which are useful but not game changers). You could get a lot of useful features with gcc 4.6 (but take the 4.6.3 version to avoid many bugs) or Clang 3.1, which is nice since gcc 4.6 is also the official Android NDK compiler (if you are looking to support that).

If you are looking to support Linux, you can take a look at DistroWatch, where you can see which gcc versions were installed for each distro version. E.g. many popular distributions based on Ubuntu have been on gcc 4.7 for almost a year now, and are going to upgrade to gcc 4.8.1 (feature complete) in their next releases.

On Windows, there is the Nuwen Distro currently running MinGW 4.8.1 (only 32-bit and no threading). Visual C++ is not up to the job and will take a while (year or more?) to get where gcc 4.8 and Clang 3.3 are.

Even if the distros don't officially support a recent version, there are private package repositories (often maintained by the same people also doing the official packaging) that provide cutting edge. The LLVM project even provides pre-built nightly SVN snapshots that enable many of the C++14 features (in -std=c++1y mode). For gcc there are no nightly packages AFAIK.

About forcing developers to upgrade compilers / distros. I don't think it is such a big deal (but the point by @ArneMertz about consulting with them first, is very good here). Virtual machines are a breeze to install (~45 minutes end-to-end), so if you only want to release a binary-only product, then go ahead. For users that's another matter, so if you are providing a header-only template library that all regular users need to compile, that should make you a lot more conservative in your transition pace.

TemplateRex
  • 69,038
  • 19
  • 164
  • 304
4

I think this is a hard one to answer, since its a somewhat broad question. You are asking about "adoption in the general public", and that is quite dependent on how you define that.

I'd say in the majority of companies adoption of new compilers is slow, because for larger projects changing parts of the toolchain comes with some costs and risks. This is true especially for bigger and "older" companies. Smaller startups often are more likely to embrace new technology.

Open source projects on the other hand are often composed of people that do programming for fun and are keen to adopt new promising things. I am sure that many of your fellow contributors will feel the same as you. How your user community adopts the new compilers can not be said without knowing more about your projects. There are projects and communities that just want the program to work and don't care about newer compilers, and there are communities that will want you to use the newest technology available, because it's cool, faster, better, whatever.

Bottom line: Ask the other contributors of your projects how the think about adopting the new standard, as well as the user community of your projects.

Arne Mertz
  • 24,171
  • 3
  • 51
  • 90