tags:

views:

553

answers:

6

I've barely/rarely used C++ in the past decade, and now it looks like I'll be doing something in it again. I'm looking forward to it, but have to wonder how it's changed since I last used it.

Are there any good / brief web pages, blog posts, or even books on how C++ has changed in the past decade?

Please note this question is regarding the language as well as tools or any additional information about working in C++. Specifically I'm working in Windows, using VC++2008.

+11  A: 

The biggest change is that C++ standard actually works in all major compilers now. Things like member templates used to be iffy.

Arkadiy
and the Standard Template Library really is a standard that can be relied upon with most major compiler vendors.
the_mandrill
Well, the Standard Library can be.
anon
+2  A: 

VS2008 comes with TR1, a large addition to std that contains things like static arrays, reference counting pointers, and suchlike. Apart from that, the biggest change is just that the compiler compiles how the Standard defines.

DeadMG
Thanks for the link edit.
DeadMG
+12  A: 

The language itself has not changed much. However, the best practices and idioms did a lot.

I suggest you take a look at the book "C++ Coding Standards: 101 Rules, Guidelines, and Best Practices" by Herb Sutter and Andrei Alexandrescu to see how modern C++ looks like today.

Nemanja Trifunovic
+1: I also wanted to write the same answer - the change in the "mindset" of the developers is by far the most important one.
IanH
+18  A: 

While the official standard hasn't changed much over the past decade or so, there are several things of importance that have happened:

  • while it's not an official standard yet, an upcoming new standard (commonly called C++0x) is 'around the corner'. GCC and MSVC 2010 have incorporated significant parts of that new standard, but I'm not sure how much is in common use.
  • the Boost library has become a major player in providing additional support for the language - to the point that it was a significant influence on the new standard
  • 'template-based' programming techniques have become much more prevalent, probably overtaking the older 'inheritence-based' techniques of code reuse (this might have been well underway when you last looked at C++ depending on the practives your shop may have been using at the time).
  • compilers (and in particular Microsoft's) have come a long way in standards compliance
Michael Burr
John MacIntyre
@John: Boost is a HUGE part of modern C++. Virtually all serious projects depend on Boost.
DeadMG
Well, I use Boost in one of my projects (for the random number library), but as for it being HUGE, I would say rather diffuse and very badly documented. The few really important bits are now part of C++0x.
anon
@John MacIntyre: Most initial uses of templates were similar to *generics* in other languages, but it has developed over the last few years as a complete different beast with template metaprogramming.
David Rodríguez - dribeas
@Neil: As DeadMG's comment qualified: "serious projects".
dman
@dman Witty. You and DeadMG are two of a kind.
anon
"Virtually all serious projects depend on boost?" Got any numbers on that or are you just pulling that one out of the air? Unfortunately our customer makes it impossible to use boost.
Brian Neal
Then sell it as "As our C++ compiler does not yet support ISO C++ TR1, we use an independent, free implementation of ISO C++ TR1". Boost is of course more than strictly required, but that same can be said of pretty much any standard library implemenation.
MSalters
@DeadMg: "Virtually all serious projects depend on Boost." - I don't think so. A lot of C++ projects were started in a time where Boost didn't existed - and never changed to boost. So maybe you are right, when saying "... all serious NEW projects ...".
IanH
86.7 percent of all "absolute statements" are wrong.
JustBoo
+9  A: 

I think one of the biggest changes is one of mindset: many people have (finally!) realised that templates are incredibly powerful and don't need to be slow, and use of the STL and boost is much more widespread than 10 years ago.

the_mandrill
And maybe in another 10 years, people will have stopped calling the Standard Library "STL".
Mike Seymour
+1 - I wish you'd tell that to the guys at work who spread 10 year old FUD about templates and exceptions.
Brian Neal
Bjarne Stroustrup still refers to it as the STL many times on his website, so I think it's fair to say it's pretty engrained. Personally, as long as people make use of it I couldn't care less what they call it :-)
the_mandrill
@Brian: I saw a great talk by Scott Meyers a few years ago who showed that even for embedded development you can use templates to create exactly the same code as if you'd hand-optimised it, and have something more powerful and flexible into the bargain.
the_mandrill
+2  A: 

An interesting question as I'm coming up to my 10th anniversary of programming C++ for coins.

My personal view is that I'd be somewhat wary -- but only somewhat -- since I haven't seen it all (though I think I can guess what it's like) -- of paying strong attention to the internet echo chamber. It's true, some people have gone full bore for the modern style of C++, with everything fully template'd up and using modern techniques to get the compiler doing its Prolog thing to best effect. However this is certainly not universally true, and, in the main, the C++ code I see today is very similar in most ways to the C++ code I saw ten years ago.

It would be a good idea to brush up on modern fashions, because some stuff that was somewhat rare ten years ago (smart pointers, regular use of RAII, standard library containers and stuff) is now more common. But unless you are sure that the code you will be working with is festooned with templates and boost and so on, you stand a good chance of working with something that's at heart very much like what you used to work with.

It may be unfashionable to say it, but that doesn't make it any less true: regardless of skill level, lots of people don't care for modern C++. Some, because they don't understand it. Some, because they do understand it. And for some, perhaps "care" isn't even the right word -- they don't even know it exists. And as you might expect these people all code accordingly.

Perhaps I move in the wrong circles, but my experience has been people who don't or can't or won't code in the modern style outnumber those that might do by some vast margin. And those who might do, generally don't, because they're outnumbered. Their code gets rewritten, or ignored, until they start writing stuff that other people can understand. So maybe this is good, or maybe this is bad -- it's hardly relevant, in my view, because the outcome is the same: that if your experience turns out to be anything like mine, you have a good chance of encountering today code that's remarkably similar to what you would have seen in 1999.

P.S. Nicolai Josuttis has written a couple of books that my last employer's resident template expert seemed to like. Also try Modern C++ Design (Alexandrescu) -- probably a bit dated now, but it explains many of the principles. Herb Sutter's Exceptional C++ gives, as I recall from a skim of a work copy, a good overview of some modern techniques without going too nuts on the template front. And of course boost demonstrates all this sort of thing (and much, much more -- then some bonus material) put into practice over a range of compilers.

(Hopefully the above list is not too dated; as my answer might suggest, I have found much less of a need to keep up to date with the latest trends in C++ than I would ever have expected.)

brone
If smart pointers and RAII were rare 10 years ago, what were the people you knew doing with the language??? as far as I'm concerned RAII is, and always has been, C++'s killer feature.
anon
Well... they were programming it like it was Objective C, or Java, or something of that ilk. Or like it was C. But always using enough C++ stuff to make it definitely C++ rather than something else! (This style of coding really doesn't play to the language's strengths, to say the least, which is why I imagine RAII, amongst other things, has become more widespread.)
brone
@Neil: Couldn't agree more. RAII is what keeps me coming back to C++ time and time again. I won't touch Java for that reason alone!
Drew Hall
BTW to any negative voters -- this all happened just as I relate it, and I hope your downvotes will help improve matters :)
brone
+1 Thanks @brone
John MacIntyre