C++0x Finally Becomes a Standard
Samfer writes "On Friday August 12th 2011, the results for the final ISO ballot on C++0x came in, and the ISO C++ Standards Committee were unanimous in favor of approving the new C++0x (for now unofficially known as C++11) object-oriented programming language standard which is intended to replace the existing C++ standard. The new standard is to offer new and improved features such as lambda functions, concurrent programming functionality, direct data field initialization, and an improved standard library to name but a few."
Although I haven't heavily used C++ in years, it is nice to see a decade long effort finally come to fruition. Especially nice is the support for type inference which should save quite a few people from RSI and make refactoring code a bit less obnoxious.
After the standard is before the standard...
Unofficially, ours increments up to eleven!
Bill Stewart
New Fast-Compression-only CPR http://preview.tinyurl.com/dy575ks
Wrong thread dude, think you were looking for:
http://developers.slashdot.org/story/11/07/28/1758221/Oracle-Announces-Java-SE-7
List of missing features:
- coroutines
- multi-stage/active library programming (i.e., something that fixes the syntactical mess of most template libraries)
- precise garbage collection (not that I'm missing it)
- fully opening up of the memory model (allowing libraries to implement complex memory handling such as garbage collection or persistence)
If Pandora's box is destined to be opened, *I* want to be the one to open it.
They didn't call it C++0b
Oh and didn't include garbage-collection outright ( though they did design it with gc in mind ).
...the 11th plague of Egypt has arrived a little bit late.
How do you pronounce that? It's like they want to advertise that this is a baroque language.
As the inaugural copy of the reference manual for the new standard was being printed and bound, it underwent gravitational collapse due to its enormous mass and became a black hole, killing all the committee members. Stroustrup was quoted as saying that despite the misfortune, he still has confidence that the C++0x standard will help programmers be more productive and efficient.
and WOOSH there goes my karma...
Dislike the Electoral College? Lobby your state to join the National Popular Vote Interstate Compact.
What's with the random links in TFS? Specifically, why link to c2.com for "type inference" and intel.com for "lambda functions"? Wikipedia wasn't good enough for those?
I've been looking at 'C' code lately. Clean, cool, crisp and refreshing Standard K&R 'C'.
I see the small tight executables.
The fast load times,
The tiny memory footprint.
And I ask myself, "What have we really gained with C++?" or any OOP language, for that matter.
Perl 6 should arrive in 2019. p.s., As for lambada functions, I hear the best ones are in Buenos Aires.
As does Visual Studio 2010: http://blogs.msdn.com/b/vcblog/archive/2010/04/06/c-0x-core-language-features-in-vc10-the-table.aspx
RAII and reference-counting.
I prefer using a program that doesn't periodically stop responding for several seconds, and shove all my other programs into swap, while it re-builds its heap.
You have RAII. You have smart pointers. Why would you need garbage collection? Only in very exceptional cases I think. The problem seems to be Java-Programmers who don't understand the concept of RAII.
make refactoring code a bit less obnoxious.
Speaking of obnoxious, what's with the 'C++0x' name?
It's nice that they finally got the standard done. But there's so much junk in there. The C++ committee was dominated by people who wanted to do cool things with templates.
Some years ago, someone figured out that it was possible to abuse the C++ template system into doing arbitrary computations at compile time. This developed a fan club. That fan club has dominated the C++ standards committee, because nobody else cared. So now we have a standard for C++ which supports template-based programming a little better.
Current thinking seems to be that,while template programming is too hard for ordinary programmers, the templates will be written by l33t programmers and then be used by the lower classes. Unfortunately, if anything goes wrong, the end user has to look at the innards of the template to find the problem. We went through this with LISP decades ago. Check out the MIT Loop Macro, That finally became stable about the time LISP died out.
Note what isn't in the new C++. There's no more memory safety than in the old one. (Fans will say that it's safer if you only use the new features. Now try to call some library that doesn't use them.) So the buffer overflow attacks and crashes will continue.
C++ is the only language to offer hiding without memory safety. Hard-compiled languages from Pascal through Go have hiding with safety, as do all the major scripting languages. C has neither hiding nor safety; the pointer manipulations are right there in the source. There have been safe, hard-compiled languages without garbage collection, most notably Ada and the Modula family. Safety and speed are not incompatible.
It took that long for a standard update.
Having a nee standard every few years is not good, that's clear.
But spending 8 years to refine/define one sounds quite a lot in the 21st century.
Sent as ripples into the electromagnetic field. No single photon has been harmed in the process.
Sadly no one thought to throw an exception when it did.
First DNF, then a HURD kernel, now C++0x... Remind me to send some parkas to hell.
yeah, they have that, it's called "pascal"
...unlike C# which Microsoft seems to enjoy having confusion surround (see the HTML/JavaScript fiasco)
It is not confusing. Microsoft used HTML/Javascript for Active Desktop. They used HTML/Javascript for Windows Explorer folder views. They used HTML/Javascript for Windows Sidebar. And they will use HTML/Javascript for the tile interface of Windows 8. It doesn't mean that .NET will disappear, just like .NET did not spell the demised of the standard Windows API.
or Java, which Oracle seems intent on bringing confusion, branding, and licensing to
It has always had branding and licensing, long before Oracle came on the scene. Look at how they went after Microsoft for license and trademark violations.
C++ has managed to evolve for how many years now?
But have they managed to actually implement the features that people want? I have just been reading up on the changes to this new version, and a lot of it seems to be fixing things problems that only exist because of stuff ups in the last version. Java and .NET offer much more than C++, and do it with cleaner code. Sure operator overloading might make some mathematical classes cleaner in C++, but the horrible template interface makes your code appear like it being seen through a haze of line noise.
Remember to test your sarcasm detector twice a year and replace the batteries regularly.
Have you SEEN the stuff they're adding in the C++0x standard? Java has its warts, but it doesn't even come close to THAT level of horrific ugliness. I think APL is starting to have a competitor for unreadable code.
You probably posted that comment using software written in C++.
And you probably posted the comment using software written in C.
the preceding comment is my own and in no way reflects the opinion of the Joint Chiefs of Staff
Someone who actually gets it. Garbage collection is a crappy hack that caters to shitty, incompetent programmers. The kiddies should look up RAII. They might learn something.
Necessity may be the mother of invention, but laziness is the lil' bastard's father.
the preceding comment is my own and in no way reflects the opinion of the Joint Chiefs of Staff
Say what you will but I've recently decided to go back to my roots and work in C and C++ just for that reason -- there's never a loud outcry that the languages will die a horrible death or go anywhere.
Amen, brother! I've just presented the same argument here. After Python 3 came out, for me it's just C or C++ for programs that need to last for an indeterminate time.
> I blame OOP as one of the reasons for the increasing bloat of software. Not in the same ball park as BASIC, java & .net.
I have the same impression. A bunch of useless, error prone, legibility degrading changes to save a little bit of typing. In my opinion this is the worst standards committee ever.
(+ x y z) is perfectly valid in Lisp
So (+ A (* B C) ( * A D))
is better style.
Bad analogies are like waxing a monkey with a rainbow.
While C++ has and always has had plenty of crap in it, I still find it hilarious that C++ got lambda before java did.
I am trolling
> The problem seems to be Java-Programmers who
> don't understand the concept of RAII.
Don't worry, most of them probably don't understand garbage collection, either. They just think it's a magical black box that does magic things... and then look bemused when they have a core leak.
Do daemons dream of electric sleep()?
So C++ takes another step closer to Lisp (lambda functions) whilst completely missing the most important part (closures and higher order programming).
I look forward to C++ 2031 when they implement garbage collection but still require you to place and remove locks on memory ;)
*Ducks and runs for cover*
Bad analogies are like waxing a monkey with a rainbow.
type inference which should save quite a few people from RSI
... and never coded anything beyond a two-dice simulation.
Because surely, the hard work of writing code is in all that typing.
and make refactoring code a bit less obnoxious
Because yeah, refactoring is all about continuously retyping your variables.
I haven't heavily used C++ in years
My karma ran over your dogma
OK, so you consider concurrency useless? And lambda functions? And type inference? And strongly typed enums? And static assertions? And Unicode support? And variadic templates? And move semantics?
The only pity is that concepts didn't make it in.
The Tao of math: The numbers you can count are not the real numbers.
I hadn't thought of that, but your right, it IS damn funny!
Seriously? People are still confused about that?
They showed off their new tile interface for Windows 8 and Microsoft did not say anything about .NET _or_ C++. Clearly, this means that .NET is being kicked to the curb.
Sure, their bet in the mobile space depends on .NET. Their browser extension, which recently just got a major revision depends on .NET. And they are rumored to be adding .NET to the Xbox by the way of Silverlight, and they already use it exclusively with XNA on the Xbox.
Top it off with the fact that Microsoft is moving to a new architecture and what makes sense? Keeping their MSIL-based binaries going. After all, the C++ binaries--without some sort of "universal" extension like Mac OS X had between PowerPC and x86--won't work. What will? .NET.
Realistically, I do not even think Java is really in a confused state. The only confusion is whether or not someone can roll their own JVM, and whether they will play ball with Apache on the committee level.
I am all for C++, and if anything, I am more shocked that C++ has been able to pick up features before Java. C++ beat Java to lambda expressions (coming in its own form in Java in December 2012--Java 8) and automatic type deduction (Java's approach realized in Java 7 late last month is to enable programmers to avoid typing in the generic arguments on the right hand side of the expression: List<String> list = new ArrayList<>();).
OK, so you consider concurrency useless? And lambda functions? And type inference? And strongly typed enums? And static assertions? And Unicode support? And variadic templates? And move semantics?
Of course they don't. But they can't troll and sound like they have a legitimate grip is they actually spoke to reality.
Given the new pointer types: unique_ptr, shared_ptr, and weak_ptr, I'd say that the spec actually disagrees with you. You practically never actually need to call delete if you use them.
It even provides the basis for implementing a garbage collector within C++ (ABI), although one is not required to meet the spec.
It's quite fair to compare and contrast C#, Java, and C++ as long as you realize they each offer benefits, with trade offs. Not to mention, Java nor C# are truly interpreted. They are both compiled locally to native code on the local machine, which can potentially lead to better optimizations than the else-where compiled C++ binaries. In practice, the C++ will still be faster, but lets not get ahead of ourselves.
They are both compiled locally to native code on the local machine, which can potentially lead to better optimizations than the else-where compiled C++ binaries. In practice, the C++ will still be faster, but lets not get ahead of ourselves.
And if you want the benefit of optimization based on runtime data such as in .NET or Java, just use Profile-guided optimization which has been available in MSVC++, Intel's C++ compiler and GCC for years now. You get all the benefits of a runtime optimization of a JIT-compiled language without the overhead combined with much more extensive compile-time optimization that you don't usually get with say Java or a .NET language.
That's because in C++, overflow is simply undefined behaviour.
The Tao of math: The numbers you can count are not the real numbers.
Which is why many of them still write code that leaks memory even with a garbage collector. One of the worst offenders are the .NET programmers who write software that leaks GDI handles like crazy and cause all sorts of crashes and bizarre behavior because they didn't bother to learn anything about managing memory and realizing that *gasp* even in a GC language you still need to make sure to be careful that all your resources are being properly released. This is further compounded because there have been a number of bugs in .NET that have caused even well-written code to leak GDI handles.
How is it not very accurate when both lists say basically the exact same thing?
Not really. The main advantage of objects is the loose coupling.
I always thought that well-executed structured and modular programming exhibited loose coupling all along, and that poorly executed OO programming would not (and currently does not just by taking a whiff at the majority of the code base out there written in a OOP language.)
But I guess I was dreaming or I was smoking some serious weed, and the reality is that objects are a necessary condition for loose coupling. Silly me.
Am I bitter and jaded? I can't help but view those comment as biting sarcasm. Is it possible the poster is simply being nice and optimistic?
a closure (also lexical closure, function closure or function value) is a function together with a referencing environment for the nonlocal names (free variables) of that function.
C++0x has exactly that with lambda functions. No one is redefining anything. For example:
[](int x, int y) { return x + y; }
This is a perfectly valid example of a closure that fits the accepted definition of what a closure is.
There are also various dynamic programming algorithms which simply have runtime memory behavior which is too complex for manual memory management.
Then use the built-in dynamic memory management support of the language.
*facepalm* indeed.
The argument the article makes is the same as a C programmer claiming he can implement classes and instances in C using structs and pointers.
True, of course, but a real pain in the arse.
A class instance can be used to simulate *some* of the most basic features of a closure but none of the really useful stuff- and it's a pain.
If C++ supported closures you could replace the ~10 lines of C++ code in the example you linked to with 3- and you wouldn't need to create the clutter of a new class to just to create a closure.
Bad analogies are like waxing a monkey with a rainbow.
They're getting C++ ready for a heterogeneous computing system. Can you imagine hand rolling code that will leverage an integrated GPU, a discrete GPU, a co-processor, and a 32 thread main CPU? Are you going to manage allocation copying and deallocation across all those devices?
Remember, in the next decade, we may see hundreds of computer configurations with mixtures between Intel larrabee, AMD Fusion, multiple GPUs, and even cloud computing as an extension of the computer. You will be able to write code once and it will not only run on it all, but it will also leverage all the resources available. Hand coding that would be a nightmare.
You're looking at the past when you should be looking at the future.
If I add a new public function to a class why should have to re-compile all the old code that doesn't use that function?
Other languages can manage not to require that so why can't C++?
Bad analogies are like waxing a monkey with a rainbow.
After all, C++0x has only taken, what, 4 years? Perl 6 has been brewing since July, 2000. (Maybe by Christmas?)
Lisp, the oldest language with GC, solved that problem a long time ago. Here's a simple example for opening a file and writing to it and ensuring all resources are released no matter what happens.
(with-open-file (s p :direction :output :if-exists :supersede)
(format s "Here are a couple~%of test data lines~%"))
Just because C++ can't/doesn't do it/makes it a pain doesn't make it universally true.
Bad analogies are like waxing a monkey with a rainbow.
Not for unsigned numbers it isn't.
I think you mean
in that first example.
And you're being ridiculous. Anyone who types that is an idiot and deserves everything they get. The actual nice thing about "auto" is that you can type
instead of
without having to faff about with typedefs all over the place.
I personally like C!!
And then next year we can be more excited and call it C!1!
When we remember we are all mad, the mysteries disappear and life stands explained.
A quick perusal on Amazon didn't find anything called the C++11 Programming Language, which is what I would have expected.
I know I can read all about it online, but I like having real books... okay?
File under 'M' for 'Manic ranting'
Actually, I'd argue that with unsigned numbers, overflow does not exist because unsigned arithmetic is defined modulo 2^N. But anyway, for unsigned overflow throwing an exception would not even be allowed.
The Tao of math: The numbers you can count are not the real numbers.
This standard is late and is full of little quirks.
It has some pretty nice stuff, but some areas still leave to be desired.
Hopefully evolution will resume now, and the upcoming work and standardizing meta-programming, domain-specific embedded languages, AST manipulation, polymorphic lambdas, constrained templates, concepts, axioms and modules will be able to take form.
Even still it's very rare to see such resources run out from a .NET application, especially these days.
Actually it's not. There are still some very popular GUI toolkits built on .NET that will leak GDI handles.
I know. It's awful! They're holding us at gunpoint and making us use all of the features we don't like!
Filthy, filthy copyrapists!
C# isn't going anywhere. Their lack of support for this newfangled interface in Windows 8 does not mean they're dropping it.
Isn't it good news then that C# for example supports garbage collection, but still lets you manage the memory if you prefer? I'm working on two projects at the mo, one mostly with GC, and one mostly without.
(perhaps you forgot the rule of premature optimization, and easy trap to fall in to).
Why OpalCalc is the best Windows calc
Nested functions are now supported very nicely in gcc, but not g++ for some unfathomable reason.
Have you got your LWN subscription yet?
There are are a lot of examples for type inference that do exactly that. I would still rather have a more verbose and informative typedef in code that I am reading than the word "auto".
Has Intel, PGI, Microsoft or IBM committed to producing a commercial quality C++0x compiler?
get a C++0x compiler that supports PIC12F508 microcontrollers?
I thought we had all the programming languages we need. After Java, we shouldn't have needed anything more. But if we were to have a step higher than C++, why this bizarre name? Why not D, or P (after BCPL)? And what does this language do that no other does well? (No, I don't know what lambda functions are - will look it up in Wiki)
Um, no. You have to be a robot to be a C++ programmer. Writing C++ is absurdly cumbersome and error-prone (what's the standard up to now, 1500 pages?) for some theoretical "efficiency" gain.
The smart way would be to choose a language which helps you get the job done with the minimum amount of fuss. If that entails extreme efficiency, then maybe you'll want to use C++ (or more likely C), but there are very few places these days where has any place.
HAND.
C++0xB is a cleverer name since it can be interpreted in two ways:
1) Since C++0x wasn't completed in 200x as expected, it's time for plan B, namely C++0xB.
2) 0xB represents 11, since 0x is the prefix for hexadecimal in C++. And so C++0xB still literally means the version finalised in 2011.
While I partially agree with you to some extent, it's not always possible to do that with heavily templated code.
Ditto, and more importantly, if I add a private data member why should I have to re-compile anything other than the class?
Private members are not even a part of the public interface!
When you add a data member (private or otherwise) it changes the memory foot print of an object. If the compiler forced everything to have an implied pImpl (allocating everything on the heap) then it could probably get away with out a recompile but at the cost of performance. Since you can allocate objects on the stack (or possibly even simple ones in registers), the memory foot print of the object needs to be known by the user of the class.
however, they did say plenty about 'Going Native' where the focus is back on native code. The story behind the story is that the 2 teams at MS have been playing politics for years, each one refusing to work with the other, and to date the Developer Division team has been pushing for their nice new languages and frameworks that the Windows Div team didn't like (apparently they tried it and it didn't work for them), now things are getting consolidated at MS they've been told to play nice and the Windows team has basically won (as they're a bit more important), so we'll be getting tools that they want rather than the tools the developer division wants to give us.
I'm sure .NET will not be dead, but you will see some sort of XAML-based GUIs available in native code, and you will see HTML5+JS as the primary GUI framework for Windows 8/Windows Phone.
you'll find that critical finalisation is incredibly hard to get right. this is why Microsoft added smart pointers (safehandle) to .NET, they couldn't get it to work properly any other way. Now when you're fixing GC with a smart pointer you have to question whether RAII would have been a better system all along.
Google for 'brumme safehandle' for his long blog post detailing exactly why it was added and what it does.
In Soviet Russia Rccp compiles you. Obviously my first attempt was a typo. Also slashdot borked my R operators which were supposed to be [<-, [[<- etc.
Now I see Slashdot also borked some words nearby while entirely failing to notify me of its textual appetites. Lazarus to the rescue, which by some miracle of resurrection has translated < to < for me.
==Restoration of slashdot borkage==
R operators [], []<-, [[]], [[]]<- do the same kind of type polymorphism at runtime that generic programming in C++ does at compile time, only with an even poorer sense of what the interface is required to document. Because of stupid semantics to automatically drop rank to eliminate dimensions of length 1, you can't even get your rank analysis correct half the time. APL had this nailed in 1965. (The stupid drop semantics can be disabled if you subscribe to the long list of "things to remember" so often used to flail C++.) To get rank analysis right, you have to distinguish scalar values from vectors of length 1, which R does not do on your behalf. In the context of a list, operator [[]] behaves like a scalar subscript, shedding a subscript dimension, while [] behaves like a vector subscript, slicing the object into a subset, by not changing rank or type. In other words, even in cases where STL would tell you that your algorithm is generic, in R you have to dispatch on type to get your subscript syntax right.
Both these languages suck a dozen ways from Sunday, but in the union of the two I'm happy as a pig in mud. Deep down I'm fairly certain that if any of 90% of the sentiment about C++ expressed on this thread had taken root in the C++ standards committee, I wouldn't now be enjoying the goodness and broad shoulders of Rcpp.
I am not sure that having a XAML front-end for C++ GUIs is necessarily a bad thing, or even a negative for .NET. It certainly takes a feather out of .NET's hat, but it actually brings the two closer together. Suddenly, they can share their knowledge and experience, and C++ gets a much better UI framework than MVC.
Similarly, and just as supposedly, Microsoft is finally adding .NET APIs alongside the native APIs. This will make .NET a first class citizen and hopefully put to bed these rumors.
I also do not think that Microsoft will do anything except make HTML5+JS a first class citizen as well. I doubt that they really want to try to beat out both C++ and .NET with HTML5+JS. I am sure that they will add it as a new option, but I both doubt and hope that they do not expect a shift to it. Although, I do wonder how the hooks would work and in terms of attractiveness and customizability, it certainly would be pretty high up there (when done right).
XAML in C++ is something they should have done from the start, but then they should have gotten a much better way to bind a variable to an element - how many lines of code did MFC need to do this? 2, and that included the line for the variable definition. C# requires a whole object plus properties :)
The thing that struck me is that there isn't much different between XAML+c# and HTML+js. Both are xml-based declarative markups that you associate code with. The biggest difference is that you associate code in script form with HTML so you don't need to go compiling anything. This probably makes it a better choice and ultimately means that GUI development will be better then the old XAML assemblies we've had to work with before. I imagine MS will add some custom extensions to HTML before long, as is their way.
Anyway, doesn't matter what we think, what works for the WinPhone is what we'll be getting whether we like it or not :(
Straw men, hurling insults, moving the goal posts, etc. etc.
You still didn't answer my point: Why should I (as a programmer) be bothered by things that the computer can do for me? (And if your accusation that we are all 'idiots' is to be taken seriously, the computer would do it better.)
C++ has advantages. Not just ones that matter in this day and age where programmer time is more expensive than computer time. The disadvantages far outweigh its advantages.
HAND.