News for hackers. Stuff that matters.
Re:C++ For C Programmers by CraigJPerry on Monday October 14, 2013 @07:28AM (#6546609)
You're the first person i've heard of who falls back to C++, if that data point is of any value.

AIUI exceptions and RAII are mutually exclusive in C++. I don't know enough about C++ so i wouldn't be surprised to find out this is wrong.

Re:C++ For C Programmers by jacobparker on Monday October 14, 2013 @07:56AM (#6546684)
> AIUI exceptions and RAII are mutually exclusive in C++

That is... very wrong. Exceptions are perilous unless you use RAII religiously (which you should; it's good.)

For more information, read up on RAII and search for "exception safety."

The definition of C++ RAII from Wikipedia: "In this language, if an exception is thrown, and proper exception handling is in place, the only code that will be executed for the current scope are the destructors of objects declared in that scope". Without this it is very hard to reap any benefits of exceptions (people have disagreements on what those are, if any, but that's another topic).

Re:C++ For C Programmers by CraigJPerry on Monday October 14, 2013 @06:51PM (#6550139)
Up-voted a few of the others below too.

I also found this which I thought was a high quality summary: http://www.parashift.com/c++-faq-lite/ctors-can-throw.html

Re:C++ For C Programmers by archangel_one on Monday October 14, 2013 @07:35AM (#6546626)
Exceptions and RAII match well, actually. Managing resources via RAII means that when an exception is thrown, the destructors of local objects are invoked so they'll release resources they've acquired.

In fact, I'd argue that you very often have to use RAII with exceptions, since there's no 'finally' block on a try-catch statement and hence it's the easiest way to ensure stuff gets cleaned up (well, except for catch(...) and rethrowing, but that's kinda ugly).

Re:C++ For C Programmers by eliasmacpherson on Monday October 14, 2013 @08:19AM (#6546766)
correct me if I am wrong but you can't rethrow in a destructor and hence RAII is required if you are using exceptions - because the cleanup and reporting work must be done in the destructor - unless you use global state to track failures and check after every attempted release of a resource i.e. C error checking.
Re:C++ For C Programmers by pjmlp on Monday October 14, 2013 @08:23AM (#6546786)
> You're the first person i've heard of who falls back to C++, if that data point is of any value.

Every time I write C code is at a gun point of being forced to do so. When I have the choice between C++ and C, I always pick up C++.

Re:C++ For C Programmers by berkut on Monday October 14, 2013 @08:34AM (#6546832)
I've tried several times to write new projects of mine from scratch in C just for a challenge, and have gone back to C++ every time.
Re:C++ For C Programmers by cldr on Monday October 14, 2013 @08:24AM (#6546793)
Not sure what AIUI means, but the very words "exception-safe" usually imply RAII.