OSDev and C++0x

Programming, for all ages and all languages.
User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

OSDev and C++0x

Post by Creature »

Hello everyone

With the release of Visual Studio 2010 and GCC 4.5 becoming closer and closer (the compiler releases that are supposed to take a major step towards C++0x), I was wondering what you think of this new "improvement" upon the C++ language. Do you think the newly added features will be useful in general (was something added that you kind of missed in C++?)? Do you see C++0x being used in kernels or operating systems (I'm referring to the ones being made here, of course). Why so?

Sorry for my barrage of questions, I'm just curious what your opinions are on C++0x. Myself, I'm kind of waiting until I can properly toy around with it. It seems to be promising but if it will really be that big of a deal, I don't know.
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: OSDev and C++0x

Post by pcmattman »

I'm mainly excited about lambdas. Whilst they could easily be abused, they are also a feature I've been missing for quite some time.

As for C++0x in a kernel? I'd say not until it's been tried and tested in applications, and even then I'd only use the features which do not require a C++0x runtime.
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: OSDev and C++0x

Post by Owen »

auto! auto! auto!
User avatar
gravaera
Member
Member
Posts: 737
Joined: Tue Jun 02, 2009 4:35 pm
Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.

Re: OSDev and C++0x

Post by gravaera »

Hi, and @OP: nice topic;

I'm with pcmattman, and I'd like to add that I also like the enhanced unicode string support idea.

--All the best
gravaera
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: OSDev and C++0x

Post by Solar »

I actually haven't had a look at the C++0x features yet. Since most of my work is maintenance coding, the vast majority of code I am handling (and will be for the forseeable future) isn't even up to par with C++ 98...
Every good solution is obvious once you've found it.
User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

Re: OSDev and C++0x

Post by Creature »

Wikipedia has a pretty nice article on C++0x for those who don't know a lot about the features yet.
pcmattman wrote:I'm mainly excited about lambdas. Whilst they could easily be abused, they are also a feature I've been missing for quite some time.
gravaera wrote:I'm with pcmattman, and I'd like to add that I also like the enhanced unicode string support idea.
Lambda expressions seem to be interesting to say the least. Seems like a good alternative for especially predicates which are a bit cumbersome to code if you have a lot of them.
Owen wrote:auto! auto! auto!
Auto seems like a very useful construction, especially to replace constructions like this:
Wikipedia wrote:for (vector<int>::const_iterator itr = myvec.begin(); itr != myvec.end(); ++itr)
with this:
Wikipedia wrote:for (auto itr = myvec.begin(); itr != myvec.end(); ++itr)
I always found it kind of annoying to place the rather large type.
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: OSDev and C++0x

Post by Solar »

Owen wrote:auto! auto! auto!
That's probably the one feature I feel most negatively about. It smells too much like VB's "variant", and IMHO goes against what C++ is all about. There's no simple way to find out what an "auto" variable can do...
Every good solution is obvious once you've found it.
User avatar
AndrewAPrice
Member
Member
Posts: 2299
Joined: Mon Jun 05, 2006 11:00 pm
Location: USA (and Australia)

Re: OSDev and C++0x

Post by AndrewAPrice »

Creature wrote:
Wikipedia wrote:for (vector<int>::const_iterator itr = myvec.begin(); itr != myvec.end(); ++itr)
with this:
Wikipedia wrote:for (auto itr = myvec.begin(); itr != myvec.end(); ++itr)
I always found it kind of annoying to place the rather large type.
And most certainly beats:

Code: Select all

for(std::vector<std::vector<int>::const_iterator>::const_iterator it = myvec.begin(); it != myvec.end(); it++)
There have been circumstances where I've required that.
My OS is Perception.
User avatar
gravaera
Member
Member
Posts: 737
Joined: Tue Jun 02, 2009 4:35 pm
Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.

Re: OSDev and C++0x

Post by gravaera »

But the auto thing can lead to some serious misuses that would be plain disatrous. Maybe they could insert some serious limitations on its use and where it can be placed. Otherwise I do see some potential for inexperienced coders to go do some murky things with it.
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: OSDev and C++0x

Post by JamesM »

MessiahAndrw wrote:
Creature wrote:
Wikipedia wrote:for (vector<int>::const_iterator itr = myvec.begin(); itr != myvec.end(); ++itr)
with this:
Wikipedia wrote:for (auto itr = myvec.begin(); itr != myvec.end(); ++itr)
I always found it kind of annoying to place the rather large type.
And most certainly beats:

Code: Select all

for(std::vector<std::vector<int>::const_iterator>::const_iterator it = myvec.begin(); it != myvec.end(); it++)
There have been circumstances where I've required that.
Your typedef-fu is weak, old man.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Re: OSDev and C++0x

Post by AJ »

Hi,
gravaera wrote:But the auto thing can lead to some serious misuses that would be plain disatrous. Maybe they could insert some serious limitations on its use and where it can be placed. Otherwise I do see some potential for inexperienced coders to go do some murky things with it.
I see what you mean and there's no need to introduce things which lend themselves to too much to abuse, but IMO any language which allows pointer maths and casting of pointers is a bit of a potential minefield for inexperienced programmers anyway. I think that comes with the territory of using a language designed for systems programming.

I can't wait for C++ 0x (or will it now end up being C++ 1x?), although I'm slightly disappointed that GC and Reflection don't feature (or have at least been postponed). Maybe I'm better off using D...

Cheers,
Adam
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: OSDev and C++0x

Post by Owen »

gravaera wrote:But the auto thing can lead to some serious misuses that would be plain disatrous. Maybe they could insert some serious limitations on its use and where it can be placed. Otherwise I do see some potential for inexperienced coders to go do some murky things with it.
Your saying this in a language which is descended from a language which "makes it easy to shoot yourself in the foot" and has been described as "making it easy to blow off your leg".

--

Actually, one other thing I like: std::vector<std::pair<int, int>> is now legal (Complaints that it messes up the lexer or parser are silly when you can generate me an error whining about it precisely anyway!).

And while I'll probably not be using concepts that much directly, when they get into the STL/Boost/OtherTemplateLibs, I will be so, so glad to see the end of 8 page template error messages!

(I think the running joke in the comitte has been, for a while now, that "the X is going to be in hexadecimal". I think they should go for "The x means it's in hexadecimal", and name it something like C++0xB:p)
User avatar
Thomas
Member
Member
Posts: 281
Joined: Thu Jun 04, 2009 11:12 pm

Re: OSDev and C++0x

Post by Thomas »

Hi ,
The auto keyword seems to be very similar to var keyword in C# ( 3.0 ) . Please note that introduction of the "var / auto " keyword does not make the language dynamically typed. I find it quite useful during prototyping (esp when iterating over a collection etc ) .

-- Thomas
fronty
Member
Member
Posts: 188
Joined: Mon Jan 14, 2008 5:53 am
Location: Helsinki

Re: OSDev and C++0x

Post by fronty »

I think auto can be acceptable when used with trivial for loops in place of ugly templates but should be avoided with everything else so it is easier to check what you can do with the object. But in this case I would still prefer typedefing.
User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

Re: OSDev and C++0x

Post by Creature »

I agree that what the auto actually does can be dubious. It'll probably all work out fine for C++ STD library container types, like std::vector and such, but what will happen when we make custom classes and iterators (for our kernels, for example)? I smell hours of debugging coming up to find out the auto keyword was compiling fine but taking some unexpected type.
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
Post Reply