++ −−
The increment and decrement operators make it possible to write in an extremely terse style. In languages such as C, they made it possible to write one-liners that could do string copies:
for (p = src, q = dest; !*p; p++, q++) *q = *p;
They also encourage a programming style that, as it turns out, is reckless. Most of the buffer overrun bugs that created terrible security vulnerabilities were due to code like this.
In my own practice, I observed that when I used ++
and --
, my code tended to be
too tight, too tricky, too cryptic. So, as a matter of discipline, I don't use them
any more. I think that as a result, my coding style has become cleaner.
Get JavaScript: The Good Parts now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.