|
Spaces home Sutter's MillProfileFriendsBlog | ![]() |
Sutter's MillMusings on software, hardware, and concurrency
|
4/5/2008 Moved to http://herbsutter.wordpress.comEffective immediately, this blog has moved to WordPress:
I like Live Spaces, and I really hate moving a blog, but unfortunately the comment spam is out of control and I just can't keep up with the tools available to manage it here -- other than accepting a blog with no comments at all, which I'm unwilling to do. Your comments are too valuable to give up.
Fortunately, the new blog location retains copies of all past posts and comments -- minus the spam -- thanks to Wei Wei's wonderful Live Space Mover script. Thanks again, Wei Wei, for your support over the weekend in tweaking the script to work with my site.
So please update your bookmarks and feeds to the new blog, and please direct your new comments there as well. I've now disabled further comments here just to keep new spam out of this mothballed space, but I'll otherwise leave this up intact until people find the new location.
See you there!
3/29/2008 Trip Report: February/March 2008 ISO C++ Standards Meeting[Updated Apr 3 to note automatic deduction of return type.] The ISO C++ committee met in Bellevue, WA, USA on February 24 to Mar 1. Here’s a quick summary of what we did (with links to the relevant papers to read for more details), and information about upcoming meetings. Lambda functions and closures (N2550)For me, easily the biggest news of the meeting was that we voted lambda functions and closures into C++0x. I think this will make STL algorithms an order of magnitude more usable, and it will be a great boon to concurrent code where it's important to be able to conveniently pass around a piece of code like an object, to be invoked wherever the program sees fit (e.g., on a worker thread). C++ has always supported this via function objects, and lambdas/closures are merely syntactic sugar for writing function object. But, though "merely" a convenience, they are an incredibly powerful convenience for many reasons, including that they can be written right at the point of use instead of somewhere far away. Example: Write collection to consoleFor example, let's say you want to write each of a collection of Widgets to the console.
Or we can leverage that C++ already has a special-purpose ostream_iterator type that does what we want:
In C++0x, just use a lambda that writes the right function object on the fly:
(Usability note: The lambda version was the only one I wrote correctly the first time as I tried these examples on compilers to check them. 'Nuff said. <tease type="shameless"> Yes, that means I tried it on a compiler. No, I'm not making any product feature announcements about VC++ version 10. At least not right now. </tease>) Example: Find element with Weight() > 100For another example, let's say you want to find an element of a collection of Widgets whose weight is greater than 100. Here's what you might write today:
At this point some people will point out that (a) we have C++98 standard binder helpers like bind2nd or (b) that we have Boost's bind and lambda libraries. They don't really help much here, at least not if you're interested in having the code be readable and maintainable. If you doubt, try and see. In C++0x, you can just write:
Ah. Much better. Most algorithms are loops... hmm...In fact, every loop-like algorithm is now usable as a loop. Quick examples using std::for_each and std::transform:
Hmm. Who knows: As C++0x lambdas start to be supported in upcoming compilers, we may start getting more used to seeing "});" as the end of a loop body. Concurrency teaserFinally, want to pass a piece of code to be executed on a thread pool without tediously having to define a functor class out at namespace scope? Do it directly:
Gnarly. Other approved features
Next MeetingsHere are the next meetings of the ISO C++ standards committee, with links to meeting information where available.
The meetings are public, and if you're in the area please feel free to drop by. 3/28/2008 Concurrency Interview with DevXI recently spent an hour on the phone to talk concurrency with DevX's Alexa Weber Morales. Part 1 of that interview just went live on the web, and focuses mostly on what concurrency and parallelism are, how to take advantage of multicore chips, and whether concurrency will ever be really accessible to mainstream developers. The site seems to be having intermittent problems displaying the pages; just hit the link a few more times if it doesn't work right away. Disclaimer: I am not responsible for the article title (yikes! "whisperer"?! my goodness gracious!) and the intro blurb vastly overstates my role (Alexa is being way too kind). But it is true that it's important for us-the-industry to bring concurrency to the mainstream in a grokkable way, as we have already successfully done with OO and GUIs in the past. 3/12/2008 New Course Available: Effective ConcurrencyMany of you have kindly sent mail about my Effective Concurrency columns and asking when there'll be a course. Well, I'm happy to announce that the answer is: May 19-21, 2008. Here's the brief information (more details below):
Note on class size limit and possible waitlist: There is a hard limit on attendance at this first one (really). But if the registration site says you'll get waitlisted, don't give up: Go ahead and sign up anyway because we may be able to put together a second installment of the seminar a week or two later if there's enough interest. Finally, here's a summary of what we'll cover during the three days.
I hope to get to meet some of you here in the Seattle area! Effective Concurrency: Super Linearity and the Bigger MachineThe latest Effective Concurrency column, "Super Linearity and the Bigger Machine", just went live on DDJ's site, and will also appear in the print magazine. From the article:
I hope you enjoy it. Finally, here are links to previous Effective Concurrency columns (based on the dates they hit the web, not the magazine print issue dates):
|
||||||||||||||||||||||
|
|