The only time I saw these operators discouraged was in Douglas Crockford's JavaScript: The Good Parts book.
Quoting from the "Bad Parts" Appendix:
The increment and decrement operators make it possible to write in an extremely terse style. In languages such as C, they make 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 cryptic. So, as a matter of discipline, I don't use them anymore. I think that as a result, my coding style has become clearer.
In addition, quoting from the JSLint documentation (the code quality tool which he has written):
The ++
(increment) and --
(decrement) operators have been known to contribute to bad code by encouraging excessive trickiness. They are second only to faulty architecture in enabling to viruses and other security menaces. There is a plusplus option that prohibits the use of these operators.
He really doesn't fancy these operators... But come on! I think we can still use the ++
and --
operators without writing cryptic code. I use them, and I like them. Everyone uses them.
Note that although JSLint has the option to disallow these operators, this option is not enabled by default.