Your feelings about C++0x?
#1
Posted 08 June 2009 - 12:06 PM
I wonder if you guys already had a look at the C++0x proposal that will most likely made it into the C++ language.
Wikipedia has a nice summary of what we can expect: http://en.wikipedia.org/wiki/C%2B%2B0x
I have a lot of mixed feelings about the new features: Lots of them will make the code more readable and compact. However, they can also increase the complexity of C++ code up to a point where we may end up with unmaintainable code.
I think meta-programming based code is already on the edge of what a non meta-programming expert can understand (take a look at the boost libraries for example). If the new features are used in meta programming (oh boy - they will be used!) we'll end up with code that a "production coder" cannot understand anymore.
Also: How should new programmers learn the language with all these new features? It is already a nightmare if you start learning the language today.
How many month of daily study does it takes for a newbee to truly understand how the stl set implementation works for example? With all the new semantics the time it takes to master the language will go through the roof.
Comments?
My stuff: torus.untergrund.net <-- some diy electronic stuff and more.
#2
Posted 08 June 2009 - 12:32 PM
The meta programming features are very cool to play with, but in my experience don't end up so much in production code, although they will help creating a better implementation for standard library tools such as std::tr1::function. There will not be much people bothered with designing such functionality, so I think the increased complexity is not much of a problem.
Personally, I don't really care whether a language is easy to learn, but I don' think the learning curve of C++ is very steep either (it is very long though, and it gets steeper once you get in the outskirts of C++). Your comment is mostly focused on new people needing to learn the language. But you seem to imply that they need to learn the whole and complete language before they can begin programming. For actual production code you really only need to know the basis (like classes and const correctness and that sort of things). I could not care less if a job applicant doesn't know what variadic template arguments are, for example. You say: "How many month of daily study does it takes for a newbee to truly understand how the stl set implementation works for example?", but why does a newbie need to study how the std::set implementation works? It's not actually that important. The main thing that really makes stuff more complex is r-value references, but in essence you don't need to know about them to write actual correct code. You'll only need to know about it if performance is of utmost importance. Classes like std::set are predesigned to be as performant as possible (thereby making full use of r-value references) and obviously make full use of other the language features (such as initializer lists), which indeeds makes them less readable, but yet more usable. And in the end, isn't the latter what is most important for standard library code?
As for the things in the new specification that I'm missing or features that got dropped, I'd really liked to see modules and reflection. Especially other modern platforms like Java and .Net have a big advantage there. The current header system is totally outdated and prone to beginner errors, and reflection really helps to write more generic code. Also, they should have restricted overload resolution.
-
Currently working on: the 3D engine for Tomb Raider.
#3
Posted 08 June 2009 - 01:02 PM
For things that I would have welcomed in the language:
- Define that arithmetic right shift does a sign-extended shift. It's still implementation dependent as the comitee *still* cares about the theoretical fact that there may be non two's complement machines out there.
- Add new operators for bit-rotates on integers. This is usefull for integer code *and* gives the operator overload guys two new operators to play with.
- make integer square root, bit-scan/leading zero count and population-count part of the standard library. If these are standarized compiler-vendors can automatically replace them with intrinsics on all archtitectures. They do this with memcpy and similar primitive functions for years.
I need these integer things a lot, and as you can guess it annoys the heck out of me that I either write slow but portable code or have to rely on non-portable hacks. :-)
My stuff: torus.untergrund.net <-- some diy electronic stuff and more.
#4
Posted 08 June 2009 - 06:21 PM
.oisyn said:
AMEN! Good riddance to typing out a functor just to do a simple operation in a for_each loop or alternatively using iterators in a regular for loop with begin/end function calls!
#5
Posted 08 June 2009 - 06:53 PM
Declaring little lambdas where they are used is definately a improvement...
My stuff: torus.untergrund.net <-- some diy electronic stuff and more.
#6
Posted 09 June 2009 - 06:57 PM
.oisyn said:
#7
Posted 09 June 2009 - 08:01 PM
// some library
namespace a
{
template<class T> void foo(T);
template<class T> struct SomeContainer
{
void callFoo() { foo(*this); }
};
}
// some user stuff
namespace b
{
struct MyType { };
template<class T> void foo(T);
}
int main()
{
a::SomeContainer<b::MyType> c;
c.callFoo();
}
This doesn't compile. The call to foo() in SomeContainer<>::callFoo() is ambiguous. Why? Because b::foo is considered as SomeContainer has a template argument that comes from the b namespace. The designer of the library obviously never intended this to happen.
See also http://www.open-std..../2006/n2103.pdf, which has some actual real-world scenario's. But alas, the proposal has been rejected.
-
Currently working on: the 3D engine for Tomb Raider.
#8
Posted 10 June 2009 - 01:34 AM
I really enjoy occasional reflection based magic-tricks in languages like C# and java however the feature seems very managed to me. It would be like putting a garbage collector into the standard.
I have not spent nearly enough time reading the new standard but my favorites so far have been the auto keyword and r-value references.
#9
Posted 10 June 2009 - 09:31 AM
SmokingRope said:
I really enjoy occasional reflection based magic-tricks in languages like C# and java however the feature seems very managed to me.
It would be very nice to be able to build a generic serializer that inspects the objects by means of reflection, rather than depending on having a custom serialization implementation for every type which is very error prone (an added member will not automatically get serialized)
Quote
-
Currently working on: the 3D engine for Tomb Raider.
#10
Posted 11 June 2009 - 02:27 AM
I think reflection support using a similar structure as the garbage collector would be very cool. I still think that putting a full reflection implementation into the standard would be too heavy.
Looking at your wording again i'm not sure we can conclude one way or the other about whether you would prefer reflection support or an implementation. :lol:
#11
Posted 11 June 2009 - 05:00 PM
SmokingRope said:
Quote
Looking at your wording again i'm not sure we can conclude one way or the other about whether you would prefer reflection support or an implementation.
-
Currently working on: the 3D engine for Tomb Raider.
#12
Posted 12 June 2009 - 01:16 AM
.oisyn said:
I was thinking arguments could be passed via the old elipses '...' or the new variadic template parameters.
Do you have any thoughts about the 'not-quite-functions' including operator overloads, casts, and global operators. Do these objects all deserve full meta-information? Another would be template instantiations, will all template instantiations have full meta information and would information about template arguments be necesarry? Template member functions? Global functions? (I've never looked closely at what java and C# does in some of these areas and perhaps this isn't really as challenging as I initially thought).
Would you expect any new language syntax to be necesarry or can it be implemented entirely within the stl?
#13
Posted 12 June 2009 - 01:07 PM
SmokingRope said:
Quote
Quote
Quote
Quote
Quote
The .Net implementation is somewhat more elaborate as you can also use value-types as generic arguments, and the VM will basically recompile the bytecode.
Quote
-
Currently working on: the 3D engine for Tomb Raider.
#14
Posted 13 June 2009 - 05:08 AM
.oisyn said:
In the case of member operator overloads and casts it could be trivial to access them by their function-style names. It does seem to offer some opportunity for an alternative syntax to be introduced for example typeid(MyClass).Method("+") or some such.
For global operator overloads, do the functions become associated to the type of their first parameter or are they treated to exist within the global scope?
It does not appear that the type_info library could be used to access anything else in the global scope. Of course if this is not supported it will limit the reflection api's ability to invoke any functions in C-style applications.
#15
Posted 16 June 2009 - 12:28 AM
-
Currently working on: the 3D engine for Tomb Raider.
#16
Posted 16 June 2009 - 01:07 AM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












