次の方法で共有


PDC05 - Amazing C++ futures talk

Just went to Herb Sutter's talk on C++ futures. Really rocking stuff! Check out the slides for TLN309. (Sorry, no link yet. I hope to update it when I get it.)

The first few minutes were on general improvements to the language including future ISO standard additions.

The coolest thing here at first glance is the "auto" keyword, which is a shortcut that lets you avoid typing in the whole bloody type declaration for a variable declaration when its type can be inferred from the assignment. For instance:

before:

foo::iterator<int> i = myList.begin();

after:

auto i = myList.begin(); // Type of 'i is inferred from the assignment

There was also a bit about lamda functions. (Yes, some of this stuff is quite parallel with upcoming C# enhancements.)

The remainder of the talk was about moving C++ toward real concurrency at a high level. The goal is to help programmers avoid all the mess of dealing with individual threads and locking. With just a few new keywords ("active" and "future") you inform the compiler what parts of your program can be done asynchronously. Think of it as making your code "message based", without completly changing the syntax.

I'm sure many of you may be doubtful from my description, and perhaps wondering what I'm smoking, but all I can say is "check it out for yourself". It only hurts your brain a little bit to grok the syntax, and it's pretty easy to see how powerful the ideas are.

Of course, all this magic will need some pretty intense upgrades to the C++ runtime. As a tools developer who plays around in the blood and guts of running code, it makes my neck hairs stand on end to think about evolving tools to this new world. I'm not doubting it can be done. Rather, I'm stepping back and reappraising the mountain to be climbed.

Comments