Post

People often ask me why do I choose to do pre-increments in my for-loops instead of post-increments. The answer is actually very simple. I don't fucking know, stop asking me that.

8 reposts178 likes

Don't worry about it. It's called Pre-Increment Preference Syndrome (PIPS). It may lead to feelings of subjection to more unsolicited code reviews than others have, but otherwise it's harmless.

I've always done post-increment because 1. it's called C++ not ++C 2. examples usually do it that way but the reality is it doesn't matter in the slightest, except in extremely niche edge cases

For reverse loops C has the --> ("downto") operator. So if you want to count from i to zero you do. while (i --> 0) { printf("%d", i); } or do you do? for(size_t i = count-1, i < count; i--) or for(int i = count-1, i >= 0, i--)

Well isn't that interesting. Looks like there's an equivalent "upto" operator as well /s

It got big from the correctness culture in C++ originally though right? Something something evaluation order resulting in unnecessary copies or temps or somesuch

Im on my phone, but from memory that was always know it was more a matter of whether you had a non-trivial copy constructor or something like that

Long time ago I read that pre-increment is (veeeery slightly) more efficient but may lead to problems on some (complex) comparisons and assignments. I suppose that using post-increment became normal to avoid those ones, but probably compilers have evolved over that...