C++0x is the solution a large group of people came up with to answer a lot of problems. Articles like this one are written by people who appear to be largely ignorant of these problems. The implicit assumption here is "I'm smarter than the C++ committee." If you think that, then you should wade through the documents produced by the committee and see how you would solve these problems: http://www.open-std.org/jtc1/sc22/wg21/
Really, C++ started simply. Early cfront languages were delightful, IMHO (with a few warts, like "protected", which in hindsight were a mistake). It was C, but with a pleasing syntax for class encapsulation and virtual function dispatch. I still write most of my C++ in that language.
But then we got multiple inheritance, and operator overloading, and placement new, and constructor initializer lists, and koenig lookup, and RTTI, and templates, (pause for breath) and now garbage collection, and synchronization, and lambdas. When will it end!? Every one of this changes is justifiable in isolation, but the end result is a language that almost no one actually understands (literally: I'm not sure I know anyone in my professional circle with a solid grasp of the entirety of C++ -- contrast that with the fact that almost everyone knows C more or less perfectly).
Then you aren't using the language -- you're using C with classes. Which is fine, but don't make comments as though your usage patterns reflect the mainstream. C++ has moved well beyond C, and it's a different language now.
IMO, the roots of C++ in C are both its biggest strength, and its greatest liability. Sure, this ensures compatibility with a ton of old code, but this compatibility also adds lots of ugly warts to the language syntax. Moreover, to this day, lots of C coders are fooled into thinking that they're dealing with a language that's "C plus a few features", and they're invariably shocked when it turns out to be a totally different (and more powerful) programming environment. They then tend to complain loudly on the internet that the language is a disaster, without ever really trying to understand it for what it is.
As an aside, I think that C++ has gone too much out of its way to not introduce new keywords. That's why, for example, the syntax for lambdas looks odd and reuses previous tokens, and the new nullptr keyword is not just "null." If you're unwilling to break old programs, then you can never clean up; think OSX vs. Windows, or even Python's willingness to break compatibility with version 3.
Somebody missed the point of the name... C99 was C9x before it was officially accepted in 1999; C++0x will likely end up as C++ 09 when it (perhaps) gets accepted next year.
Actually, the whole rant is largely just a rant, quite clueless and poorly argued in places (e.g. nullptr vs NULL). However, it's hard not to agree that auto function and lambda syntax (the -> and [] things) and rvalue references are astonishingly bad additions. It's obvious that Boost people have very strong influence on a committee, because hardly anyone else outside of Boost needs these features.
for (std::vector<int>::const_iterator i = vec.begin(); i != vec.end(); ++i)
Versus, for (auto i = vec.begin(); i != vec.end(); ++i)
How is auto an astonishingly bad addition again?Rvalue references solve a problem that library writers who are concerned with performance have. That most programmers don't need rvalue references misses the point - most programmers will probably depend on a library that benefits from rvalue references.
auto func(int x) -> double;
I realize that the above is allowed primarily for this case: auto func(int x) -> decltype(x);
but from a casual examination the following - simpler and cleaner - notation can quite easily be made unambiguous: decltype(x) func(int x);
Also, isn't typeof a more natural name for decltype ? Again I realize that the keyword overlaps with existing gcc extension, but semantics of latter is a subset of C++0x one. decltype(x) func(int x);
Is not used is that it uses x before its defined. Hence the new function declaration syntax, where the return type is delayed until after the parameter list.I actually agree that typeof is more natural, and I would prefer that keyword. But one of the committee's goals is to not have new language feature names clash with old conventions. Hence, the hashtable-based associative containers will be called unordered_, and not hash_.
Duh, noooo, really ? Have you ever wondered what magic causes this snippet to compile:
struct foo
{
foo() { bar = 1; }
int bar;
};
In other words, C++ is perfectly capable of handling forward references. Parser can simply postpone evaluating decltype() expression until it reaches the end of the function declaration. That's hardly a compiler "rocket science".I'm guessing that the real reason why they ended up with this ass-backward syntax was to try and achieve some consistency between these two cases:
auto <variable>;
auto <function>;
Was it worth it ? IMO - hell, no.This isn't slashdot. Please be civil.
Read Section 5 for the rationale provided by the committee members who proposed the syntax: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n170...
In particular, the name collision problem does not happen with classes because each class is a new scope.
I'm not sure if the author knows this, but the fact that nullptr is even needed is a design flaw of C++. That is,
int foo = NULL;
is illegal C, but legal C++. So much for C++ being more typesafe!Likewise when I see the new features in C++ I take what I can immediately understand and slowly grow into the things I don't. For example the 'auto' feature as really awesome and simple. It alone will save me many lines of code tedious code (and many more avoiding said tedious code.)
I guess I can just be happy knowing that I'll never be fluent in C++. I'll probably never understand how: http://www.boost.org/doc/libs/1_35_0/boost/bind.hpp works. But it doesn't mean I can't use it. Maybe one day I'll get into template meta-programming or maybe I'll forever gape like a tourist at the wonders the library creators bring forth.
The good thing about all these features is you don't have to use them all at once, and for situations where you want to evolve, there's always room ahead. I think for some language zealots, the expanse of the C++ frontier is somehow threatening. It's a bit like saying, I don't understand calculus so I won't use multiplication.
I do rendering engines so I really don't have a choice.
If you are not aware of the reasons C++ sucks, check out the C++ FQA (frequently questioned answers):
http://yosefk.com/c++fqa/picture.html
Finally, I completely agree with others who say: Adding more and more features to a language DOES NOT make it easier to use.
http://abhishek.geek.nz/docs/features-of-common-lisp
One simple example: Common Lisp is multi-paradigm, but has a soft spot for functional programming. So Common Lisp's Object System (CLOS), is implemented around generic functions and multiple dispatch. And generic functions are just as first class as any other function (I think, can anyone confirm this?).
Another example: supporting type declarations as hints to the compiler, but not mandating their use. This greatly reduces the "cognitive load" of this feature until you really need it.
Addition of closures, on the other hand, will make C++ a viable back-end target for a lot of cool language hackery. :o)
Please, please don’t add language features just to make
the lives of library designers easier. Add features to
make the average programmer’s life easier.
Seriously? You don't think that being able to write
libraries that integrate with the language seamlessly
will make the programmer's life easier? You think that
std::vector<int> blah;
blah.push(0);
blah.push(1);
blah.push(2);
beats
std::vector<int> blah = {0,1,2};
...The fact that in contravention of who-knows-
how-many-years of tradition, return type is going
after the function and parameter names?
Hey, just like every functional language that you
spent the last few paragraphs praising. If you'd
complained about it being inconsistent, you may have
even had a point! something like
int anon(...){...}
would probably have been a cleaner syntax, despite
being hell to parse (what in C++ isn't hell to
parse, though?)
I could go on, but I've got stuff to do. Still, if you're going to rant, please make it a well-informed rant! For the most part,the C++ FQA still applies to C++0x, among many others; plenty specific to C++0xThis really reads like a "WAHH! C++ isn't Python or Java!" post. only by someone that barely passed his C++ class in college.
Edit: Fix up formatting.
I agree with many of your points, but I think that last bit is unnecessarily harsh.