std::cout << "Hello World!" << std::endl; —

C++ coming back into the mainstream with more specs, more often

Visual Studio 2012 standard conformance updates on the way.

At BUILD in Redmond today, Microsoft announced its plans to improve C++ standards conformance in its Visual Studio development environment, and talked about ways in which C++ would become a better, regularly updated, modern programming language. Microsoft developer and C++ standard committee chair Herb Sutter introduced work being done by the C++ community to make the language better, and also discussed the work being done by Microsoft to make its own compiler better.

C++, the systems programming language, is one of the most important programming languages in the world. It's used to build important system infrastructure (operating system kernels tend still to be C, but the systems built on those kernels are often C++), and one of the first choices for development of fast, efficient software.

It's also emerging from a dark period in its history. The first version of the standard was delivered in 1998. The next didn't get finished until early 2011, after a painful and drawn-out process that saw the committee going down blind alleys and suffering political infighting. C++ has also suffered from being more than a little uncool; safe environments like Java, .NET, Python, Ruby, Node.js and more have all won considerable mindshare, and have become the go-to tools for a large class of applications, taking advantage of C++'s 13-year failure to add necessary, modern features in a timely manner.

But C++'s future is looking a lot brighter. Standards will be updated sooner, with the next major release scheduled for 2017, and a minor release in 2014. The C++ working group has created a number of subgroups to work on subjects as diverse as concurrency, file system access, and networking, and these groups will develop specifications of their own, alongside the standards, to extend the versatility of standard C++.

Microsoft, Intel, Google, IBM, and a number of other companies have also created an independent body, the Standard C++ Foundation, to promote and advocate the usage and development of modern C++.

For its part, Microsoft is taking steps to enhance the standards conformance of Visual Studio 2012. Today the company released a preview version of the C++ compiler that adds support for a range of features included in the 2011 C++ standard, including variadic templates and initializer lists.

This first preview updates only the compiler; libraries and the Visual Studio IDE itself aren't changed. By the time the compiler is finished, however, the whole lot will be updated. The company hasn't said exactly when the final versions (with IDE and library support) will be out, but implies it should be relatively soon: Redmond promised even more conformance improvements will be delivered in the first half of 2013.

About freakin' time Microsoft! As stormbeta mentioned, Microsoft's C++11 support is woefully inadequate compared to gcc/clang (the latter of which Apple heavily contributes to and uses).

As a systems and application developer, the only thing holding me back from using C++11 at this point is Microsoft's support for it (Visual Studio is really the only practical option for Win8 applications right now).

But I'm not going to hold my breath waiting for it; they never did bother implementing C99 even though most of the industry implemented almost all of it (and some vendors have 100% C99 support).

If you want a good idea of how poor their support was, just look at this page:

There's some really good stuff in the C++11 standard, for example lambdas and the new meaning of 'auto'. There's a lot of other new stuff too, and not all of it seems as immediately useful (IMO), but I'm interested to see how the language usage develops over the next couple of years, as people start making use of the new features, and best practices start to develop around them.

(Although I'm probably slightly biased, as someone who's paid to write C++ on an almost daily basis for the last 10 years or so.)

In other words, Microsoft is finally serious about catching up to GCC and clang?

Because last I checked Visual Studio 2012's compiler *still* doesn't support variadic templates, a major C++11 feature. Both GCC and clang have supported it for quite awhile now.

It's interesting that you make this claim. VS2012 is the only current compiler that I've found that gets many standards correct, including lambdas, auto, implicit make_pair requirements, etc. GCC and clang, last I check (last week, admittedly), still only had draft standard support, and no way to turn on most of this stuff without importing stuff from the tr1 namespace.

Variadic templates are nice. A buddy of mine (well, former office mate) actually was the one to put them in GCC. They solve a lot of issues, but they are still part of the C++0x mode of g++. Meaning they are not final draft standards compliant, as some of the wording and requirements changed.

Don't get me wrong, GCC is an awesome tool: a free, vaguely standards compliant compiler is great. But it's not what is used for creating commercial software.

As for why VS doesn't support C99, there isn't much motivation for them to do so. It's a Windows application development environment. Every C library for Windows application development has been deprecated for at least a decade.

In other words, Microsoft is finally serious about catching up to GCC and clang?

Because last I checked Visual Studio 2012's compiler *still* doesn't support variadic templates, a major C++11 feature. Both GCC and clang have supported it for quite awhile now.

It's interesting that you make this claim. VS2012 is the only current compiler that I've found that gets many standards correct, including lambdas, auto, implicit make_pair requirements, etc. GCC and clang, last I check (last week, admittedly), still only had draft standard support, and no way to turn on most of this stuff without importing stuff from the tr1 namespace.

Variadic templates are nice. A buddy of mine (well, former office mate) actually was the one to put them in GCC. They solve a lot of issues, but they are still part of the C++0x mode of g++. Meaning they are not final draft standards compliant, as some of the wording and requirements changed.

Don't get me wrong, GCC is an awesome tool: a free, vaguely standards compliant compiler is great. But it's not what is used for creating commercial software.

As for why VS doesn't support C99, there isn't much motivation for them to do so. It's a Windows application development environment. Every C library for Windows application development has been deprecated for at least a decade.

I'm sorry, but every time I touch the VC++ compiler toolchain I find it woefully inadequate. It does not work efficiently or effectively, even gcc is tremendously better, but of course clang is where all the exciting stuff is happening these days.

Frankly it seems good to me Microsoft is promoting C++, in any fashion. Most software today for Windows, at least in the business sector, is usually over priced poorly coded garbage thanks to the "quick" programming nature of .net and the like. Its not that .net in and of itself is poor, its that on so many occasions its implementation by developers is VERY poor. You CAN produce a quality product with VB/C#, but it requires some one with intelligence to do it. C++ tends to be "harder" and therefore weeds the crap programmers from the good ones, so the end product is better.

TheFerenc, it sounds like you're using GCC without turning on C++11 (it defaults to the 98 standard if you don't ask for the new one). What you're saying about TR1, I think, confirms it: in C++98 mode you need tr1 to get a number of classes that are included in std:: if you are in C++11 mode.

I'm in the electronic design automation industry, which for the most part uses GCC to build and ship its quite expensive commercial software. So your claim that it isn't professional grade is simply ignorant.

I'm sorry, but every time I touch the VC++ compiler toolchain I find it woefully inadequate. It does not work efficiently or effectively, even gcc is tremendously better, but of course clang is where all the exciting stuff is happening these days.

I'm not sure what you're trying to do, but nearly EVERYTHING is better than clang in my experience. clang's front end is TERRIBLE. And I'm sorry, the non-standardness of it is just galling, especially for anyone who cares about little things like POSIX/SUS compliance. "Oh, we don't like that part of the standard. Let's deprecate it, and push our slightly different version in its place!". To be fair, GCC is worse about this than clang, but still.

Also, just to point out: clang/gcc are great for hobbyists and open source coders. But in the end, real work is done by the majority of C/C++ programmers with icc and msvc -- unless they are using embedded environments...that's a WHOLE different world, and you almost always have to use a device specific dev environment.

The main exception to this is people paid to write open source code.

I'm an academic. The availability of both gcc and clang makes life so much easier when I can count on my students having access to a compiler. But they aren't very standards compliant for things like POSIX/SUS.

Frankly it seems good to me Microsoft is promoting C++, in any fashion. Most software today for Windows, at least in the business sector, is usually over priced poorly coded garbage thanks to the "quick" programming nature of .net and the like. Its not that .net in and of itself is poor, its that on so many occasions its implementation by developers is VERY poor. You CAN produce a quality product with VB/C#, but it requires some one with intelligence to do it. C++ tends to be "harder" and therefore weeds the crap programmers from the good ones, so the end product is better.

I'm not sure what you're trying to do, but nearly EVERYTHING is better than clang in my experience. clang's front end is TERRIBLE. And I'm sorry, the non-standardness of it is just galling, especially for anyone who cares about little things like POSIX/SUS compliance. "Oh, we don't like that part of the standard. Let's deprecate it, and push our slightly different version in its place!". To be fair, GCC is worse about this than clang, but still.

Also, just to point out: clang/gcc are great for hobbyists and open source coders. But in the end, real work is done by the majority of C/C++ programmers with icc and msvc -- unless they are using embedded environments...that's a WHOLE different world, and you almost always have to use a device specific dev environment.

....

Yeah THAT icc, that was on purpose crippling binaries on AMD CPUs for years (how many benchmarks in "top" magazines were done with this bogus crap?). What a fucking joke. Like there's no other compiler than icc of msvc. Esp. in HPC environment. And what about MS compiler and other languages like FORTRAN?

I'm not sure what you're trying to do, but nearly EVERYTHING is better than clang in my experience. clang's front end is TERRIBLE. And I'm sorry, the non-standardness of it is just galling, especially for anyone who cares about little things like POSIX/SUS compliance. "Oh, we don't like that part of the standard. Let's deprecate it, and push our slightly different version in its place!". To be fair, GCC is worse about this than clang, but still.

Also, just to point out: clang/gcc are great for hobbyists and open source coders. But in the end, real work is done by the majority of C/C++ programmers with icc and msvc -- unless they are using embedded environments...that's a WHOLE different world, and you almost always have to use a device specific dev environment.

....

Yeah THAT icc, that was on purpose crippling binaries on AMD CPUs for years (how many benchmarks in "top" magazines were done with this bogus crap?). What a fucking joke. Like there's no other compiler than icc of msvc. Esp. in HPC environment. And what about MS compiler and other languages like FORTRAN?

Fortran is a wholly different beast. And not the point of this discussion. I specifically stated C/C++. Also, HPC environments tend to be mostly national lab type places with wholly different requirements. BlueGene at ORNL, for instance, uses IBM's XLC.

Oh, and not all of us are working in an environment where we have the ability to upgrade the compiler. RHEL 5/6 for instance do not have a supported compiler for anything beyond C++0x mode in GCC. Oh, and I'm not an idiot, I'm quite aware of the --std flag, thanks though.

You know it's funny - about 5 years ago, after several years of maintaining other people's idiosyncratic (if not outright broken) C++ code, I started to hate the language, and started writing little projects in C in my spare time just to keep myself sane. But later in my career, I was lucky enough to work on some projects which were written by engineers with experience and a common vision of how to architect large-scale C++ applications, and I found myself starting to enjoy it again.

I think a lot of the time, people's experiences with particular codebases tend to influence their opinions of the language that the codebase is written in, when the codebase tends to reflect much more strongly the culture of the individual or team that wrote it (and of course, language choice is to some extent a cultural choice...)

And just to undermine anything I just said, I'll point out that Minecraft is written in Java.

I would really love to see C++ replaced with a more modern language, like the D programming language.

Having programmed with C++, C# and java over the last 10 years, I find the whole C++ ecosystem to be really awful: Preprocessor is powerful but a nightmare most of the time, the compilers are painfully slow, most of the code editors don't have any kind of refactoring support, even simple things like strings are reinvented 50 times, etc

I'm sorry, but every time I touch the VC++ compiler toolchain I find it woefully inadequate. It does not work efficiently or effectively, even gcc is tremendously better, but of course clang is where all the exciting stuff is happening these days.

I'm not sure what you're trying to do, but nearly EVERYTHING is better than clang in my experience. clang's front end is TERRIBLE. And I'm sorry, the non-standardness of it is just galling, especially for anyone who cares about little things like POSIX/SUS compliance. "Oh, we don't like that part of the standard. Let's deprecate it, and push our slightly different version in its place!". To be fair, GCC is worse about this than clang, but still.

Also, just to point out: clang/gcc are great for hobbyists and open source coders. But in the end, real work is done by the majority of C/C++ programmers with icc and msvc -- unless they are using embedded environments...that's a WHOLE different world, and you almost always have to use a device specific dev environment.

The main exception to this is people paid to write open source code.

I'm an academic. The availability of both gcc and clang makes life so much easier when I can count on my students having access to a compiler. But they aren't very standards compliant for things like POSIX/SUS.

Well you are a developer so instead of whining about it why not become a contributor and make gcc and clang POSIX/SUS compliant.Have you even brought up this issue with the developers on these two projects ?

I would really love to see C++ replaced with a more modern language, like the D programming language.

Having programmed with C++, C# and java over the last 10 years, I find the whole C++ ecosystem to be really awful: Preprocessor is powerful but a nightmare most of the time, the compilers are painfully slow, most of the code editors don't have any kind of refactoring support, even simple things like strings are reinvented 50 times, etc

Do not blame the language for something it can't control. Go write microsoft a letter instead.Have you tried clang compiler ? They say it is fast.

A few comments:It's interesting that you make this claim. VS2012 is the only current compiler that I've found that gets many standards correct, including lambdas, auto, implicit make_pair requirements, etc. GCC and clang, last I check (last week, admittedly), still only had draft standard support, and no way to turn on most of this stuff without importing stuff from the tr1 namespace.

It's interesting you make that claim as you clearly haven't used a recent version of LLVM/Clang; certainly not the one Apple ships in the latest version of XCode. What may be confusing you is that by default, it uses C++98; to get full C++11 support you have to specify these flags: "-stdlib=libc++ -std=c++11".

Quote:

As for why VS doesn't support C99, there isn't much motivation for them to do so. It's a Windows application development environment. Every C library for Windows application development has been deprecated for at least a decade.

Yes, and now that's come back to bite them. Windows doesn't dominate the mobile platform space; Linux and iOS do. And both of them support far more modern language features than MSVC with their compiler sets, including C99.

Their refusal to support C99 is just as curious as their insistence on not supporting OpenGL ES on Windows Phone 8 or WebGL in IE10+.

In the meantime, their refusal to support industry standards has dramatically increased the porting and maintenance costs of any developer wanting to target their platforms.

I know you're the story author, but every other compiler had support for most (or all) of C99 *years* before Microsoft did (and of course, they still don't support most of it). That, in my opinion, would have been far more useful than cherry-picking a few features here and there and ignoring the rest of the industry.

Also, just to point out: clang/gcc are great for hobbyists and open source coders. But in the end, real work is done by the majority of C/C++ programmers with icc and msvc -- unless they are using embedded environments...that's a WHOLE different world, and you almost always have to use a device specific dev environment.

You do know that Apple use Clang for OS X? That's not the embedded space.

One of the FreeBSD developers also just announced they're switching to LLVM/Clang on November 5th.

I can also assure that you many large commercial organisations are using LLVM/Clang internally for static code analysis in commercial settings, so your belief that it's just for hobbyists is flat out wrong.

Quote:

The main exception to this is people paid to write open source code.

I'm an academic. The availability of both gcc and clang makes life so much easier when I can count on my students having access to a compiler. But they aren't very standards compliant for things like POSIX/SUS.

I have no idea what the heck you think LLVM/Clang has to do with POSIX/SUS. Those are operating system standards; LLVM/Clang is a compiler suite.

You CAN produce a quality product with VB/C#, but it requires some one with intelligence to do it. C++ tends to be "harder" and therefore weeds the crap programmers from the good ones, so the end product is better.

You'd be surprised... I work on a C++ codebase that's approaching 20 years old, there's plenty of terrible designs and complete misunderstandings of the language that has accumulated. "C with classes" comes to mind. Then again, I've seen Java/C# developers on StackOverflow write some horrible C++, assuming things act just like their respective managed language. Very dangerous. In the end, anyone can write bad code regardless of what language its written in.

federico_cba wrote:

Having programmed with C++, C# and java over the last 10 years, I find the whole C++ ecosystem to be really awful: Preprocessor is powerful but a nightmare most of the time, the compilers are painfully slow, most of the code editors don't have any kind of refactoring support, even simple things like strings are reinvented 50 times, etc

Sounds to me like you really haven't been following the C++ standard over those last 10 years (it's okay, I know plenty full-time C++ devs that haven't). The preprocessor has lost a lot of its usefulness in C++11. Compile times are certainly slower, but I can typically get a couple hundred thousand lines of C++ to compile in just a few minutes on a fairly limited virtual machine. Full build of ~3 million lines takes about 20 minutes on our build machine. $100 will buy you Visual Assist X for Visual Studio, which includes great refactoring support for C++. Microsoft has unofficially stated that refactoring is on their TODO list for C++ in Visual Studio (and Herb has beat around the bush bringing up refactoring support within C++ compiler front-ends). And meh, every library/framework wants to make its own string type, but for the most part std::string (we use std::wstring at work) will do the trick. Its best not to toss a library's types into your core code anyway.

I have no idea what the heck you think LLVM/Clang has to do with POSIX/SUS. Those are operating system standards; LLVM/Clang is a compiler suite.

Which has to be supported by the compiler...but cute that you don't seem to acknowledge that.

POSIX/SUS is almost entirely a function of the operating system environment and not the compiler.

About the only way the compiler even begins to enter into it is through the standard library provided and the language features it supports.

Can you actually name something specific about LLVM/Clang that somehow is causing you grief with POSIX/SUS? I can't; and my day job is helping develop one of the few operating systems that is POSIX/SUS compliant.

Quote:

And this is a longstanding bug with the gcc people.

And as has been stated several times, I'm quite well aware of the --std flag. You can't use C++11 as an argument to --std on compilers that don't support it. Such as that supported on RHEL 5 and 6.

Whatever is supported on RHEL5/6 is irrelevant. You can download and run the latest version of LLVM/Clang on RHEL and most other Linux distributions. Likewise, GCC is also available.

If that's your central argument -- that RedHat doesn't deliver the latest version of LLVM/Clang for RHEL or one that supports C++11 -- it's a specious one at best.

The software development community will never agree about much regarding C++, but we can all agree that writing a standards-compliant C++ compiler is among the most difficult and fearsome challenges any of us could imagine. The parser alone is a monumental undertaking.

People complain that C++ compilers are dog slow or that certain features are missing or nonstandard, but I think that it's a triumph of human ingenuity and perseverance that there are any C++ compilers that work at all.