News for hackers. Stuff that matters.
Re:The Hidden Cost of C++ by huhtenberg on Tuesday October 20, 2009 @12:08PM (#892621)
There are constructors in C++. The water is wet, how sneaky of it.

You either know the code you are working with or you don't. C++ or not.

Re:The Hidden Cost of C++ by uriel on Tuesday October 20, 2009 @12:36PM (#892676)
What he is pointing out is that C++ makes it harder to 'know the code you are working with'.
Re:The Hidden Cost of C++ by huhtenberg on Tuesday October 20, 2009 @02:26PM (#892970)
I understand the point, and I am saying it is a trivial one.

Calling func(x) in C may as well be causing x to be cloned or have some other nasty side effects that are not immediately obvious from looking at the code. Similarly how one should always keep in mind the existence of macros when reading C code, one should also keep in mind the existence of constructors and casting operators with C++. That's hardly the hidden cost.

It is easier to write messy or obscure code in C++, especially for a novice programmer. But this has less to do with the language per se and more with established coding practices within specific team. If there is a hidden cost to C++, it is the fact that it requires higher level of competence. Not that it has constructors.

Re:The Hidden Cost of C++ by groby_b on Tuesday October 20, 2009 @02:43PM (#893013)
The point is that, with a rational team, I can tell (roughly) what a function is doing, based on the name. It's not going to be called 'dot_product' and clone data passed in ;)

What I can't tell is how much extra code the compiler will generate at this point, and that is the problem.

> If there is a hidden cost to C++, it is the fact that it requires higher level of competence. Not that it has constructors.

I didn't say the cost is in the constructors. They're a symptom of the cost. The cost is creating the mental model of your app.

Sure, if the entire team consisted of C++ superstars, we might be able to get away with this. Given the team size on current games, (and the fact that superstars are rare) that's unlikely to be the case.

Re:The Hidden Cost of C++ by nuserame on Tuesday October 20, 2009 @02:54PM (#893043)
If there's no enough "superstars", then perhaps your coding guidelines should accommodate that so that the "mental model" of the app would be more managaeble for the code monkeys.
Re:The Hidden Cost of C++ by groby_b on Tuesday October 20, 2009 @03:43PM (#893158)
This is not a question of "code monkeys". It's simply a question of having some programmers that are less experienced than others. And that's kind of unavoidable if you ever want to hire new people...
Re:The Hidden Cost of C++ by ubernostrum on Tuesday October 20, 2009 @12:49PM (#892715)
FWIW, I think you meant to say "what she is pointing out"...