News for hackers. Stuff that matters.
Re:In the C++ bag of tricks: scoped locks by stinos on Friday February 07, 2014 @12:31PM (#7197470)
This. For at least three typical 'best practice' reasons. I know there are times best practices can be nicely ignored, but this is not one of those occasions. On the contrary. Let me lay them out again:

- these are the days of C++11 where scoped locks are readily available

- premature optimization

- macros are evil

Re:In the C++ bag of tricks: scoped locks by pjmlp on Friday February 07, 2014 @12:34PM (#7197494)
One of the reasons C++ gets bad reputation, is those Cisms that people insist on writing, when the language offers much better alternatives.
Re:In the C++ bag of tricks: scoped locks by stinos on Friday February 07, 2014 @12:39PM (#7197522)
Which is mostly due to lack of education. If you don't ever spent time learning, but just coding, you don't know better. And sometimes it's all too easy to get thrapped into it due to deadlines and whatnot. A former collegue of mine, unfortunately, was the best example: programmed for like 15 years years and still wrote like it was all 'C with classes' (not that there ever was such a thing). You know, writing declarations at the top of functions etc. Missing out on C++11 is just as bad.
Re:In the C++ bag of tricks: scoped locks by pjmlp on Friday February 07, 2014 @02:52PM (#7198323)
Fully agree.

Personally I never liked straight C.

For me it was just a short transition between Turbo Pascal and C++, only to be used when required to do so. Around 1993 or so.

I devoured every book and publication about C++ I could put my hands on. Always trying to educate others how to write safe and portable C++.

Nowadays I am into JVM and .NET mostly, but when I reach for C++ it is with regard to the latest standards.

Every now and then, I still see C++ code that is basically the C subset without using any improvements of C++ over C.

Re:In the C++ bag of tricks: scoped locks by dmm on Friday February 07, 2014 @04:10PM (#7198750)
C with classes is what the google c++ style guide mandates: http://google-styleguide.googlecode.com/svn/trunk/cppguide.x...

No exceptions, no boost, no lambda, no rtti, streams only for logging, avoid operator overloading, etc.

Re:In the C++ bag of tricks: scoped locks by vinkelhake on Friday February 07, 2014 @05:18PM (#7199148)
The Google C++ style guide has its quirks, but describing it as "C with classes" is flat out wrong.

> no boost

Not true, select parts of Boost are available.

> no lambda

The C++11 features are being rolled in gradually. Lambda expressions are now permitted.

> no rtti

The guide says "avoid RTTI" and urges the developer to come up with a different design. This is very much in line with C++ best practice overall. There's no ban on RTTI.

Re:In the C++ bag of tricks: scoped locks by dmm on Sunday February 09, 2014 @01:17PM (#7206392)
Version 3.274 says:

Do not use lambda expressions, or the related std::function or std::bind utilities.

Re:In the C++ bag of tricks: scoped locks by vinkelhake on Monday February 10, 2014 @02:14PM (#7213006)
It's unfortunately not synched with the internal version.
Re:In the C++ bag of tricks: scoped locks by pjmlp on Friday February 07, 2014 @05:45PM (#7199282)
I don't agree with Google's style guide, besides they are not perfect.
Re:In the C++ bag of tricks: scoped locks by rmcclellan on Friday February 07, 2014 @04:11PM (#7198760)
Re:In the C++ bag of tricks: scoped locks by pjmlp on Friday February 07, 2014 @05:43PM (#7199274)
There is no reason to code in 2014 as if CFront was just released today.