C++ should have been called ++C

Except for the odd side-effect, in C, c++ is basically equivalent to ++c.

But in C++ the magnitude of those side-effects is far greater, so much so that in a bunch of stl cases where it matters, it is far more efficient to use ++c than c++. So it seems to me it would have made more sense to recognize this by calling the language ++C instead of C++.


2 Responses to “C++ should have been called ++C”

  1. IInspectable says:

    The side-effect of C++ and ++C is identical: Incrementing the stored value C. The difference is in the result of the expressions.

  2. fleeb says:

    A hidden side effect, though, is the time taken to perform the expression, which can be significant.

    In C++, the postfix operator for increment and decrement takes more time, because one needs to store the value to return it, where you do not have that need in the prefix versions.

    But, yeah, maybe we should have called it ‘++C’. For my part, I use the prefix version regularly, knowing about this simple optimization.

Leave a Reply