News for hackers. Stuff that matters.
Re:The Hidden Cost of C++ by JoeAltmaier on Tuesday October 20, 2009 @11:48AM (#892590)
I fixed a single line of code that drove our embedded processor to 50% cpu - it called 5 ctor/dtors. Changing it to a ref arg with a ref return, and dropped to under 10%. And yes, class defs had to be redeclared, the line of code was unchanged. Very indirect, utterly beyond the original authors comprehension.
Re:The Hidden Cost of C++ by hazzen on Tuesday October 20, 2009 @03:14PM (#893088)
Do you know how to fix almost every one of these cases for good? Just don't allow implicit copying of your classes. Problem solved. If someone tries to write that horrible code, they can't.

This is more a question of knowing what you are doing and less of C++ sucking. C doesn't solve this - you still have to know what you are doing there or you end up shooting yourself in the foot. I much prefer having an interface with virtual methods to a struct with function pointers.

Re:The Hidden Cost of C++ by JoeAltmaier on Wednesday October 21, 2009 @11:37AM (#894848)
Of course! However the original author of the offending code didn't know to define private X(X&), so had the problem. C++ is a power saw; you can cut off your hand.
Re:The Hidden Cost of C++ by cppppp on Tuesday October 20, 2009 @12:47PM (#892707)
Thus proving it's possible to write crap code in any language.
Re:The Hidden Cost of C++ by groby_b on Tuesday October 20, 2009 @12:48PM (#892709)
Well, yes. The point here is that C++ makes it much easier to generate crap code.
Re:The Hidden Cost of C++ by ecaradec on Wednesday October 21, 2009 @03:16AM (#894187)
Founded and fixed in exactly 5 seconds with a profiler. So what ?
Re:The Hidden Cost of C++ by psyklic on Tuesday October 20, 2009 @07:19PM (#893581)
Why do you use C++ for an embedded processor?
Re:The Hidden Cost of C++ by JoeAltmaier on Wednesday October 21, 2009 @11:38AM (#894852)
No reason not to. Control your runtime and it's fine even for OS work.