title: In regards to for(), why use i++ rather than ++i?
body: <p>Perhaps it doesn't matter to the compiler once it optimizes, but in C/C++, I see most people make a for loop in the form of:</p>
  
  <pre><code>for (i = 0; i &lt; arr.length; i++)
  </code></pre>
  
  <p>where the incrementing is done with the post fix ++. I get the difference between the two forms. i++ returns the current value of i, but then adds 1 to i on the quiet. ++i first adds 1 to i, and returns the new value (being 1 more than i was).</p>
  
  <p>I would think that i++ takes a little more work, since a previous value needs to be stored in addition to a next value: Push *(&amp;i) to stack (or load to register); increment *(&amp;i). Versus ++i: Increment *(&amp;i); then use *(&amp;i) as needed.</p>
  
  <p>(I get that the "Increment *(&amp;i)" operation may involve a register load, depending on CPU design. In which case, i++ would need either another register or a stack push.)</p>
  
  <p>Anyway, at what point, and why, did i++ become more fashionable?</p>
  
  <hr>
  
  <p>I'm inclined to believe azheglov: It's a pedagogic thing, and since most of us do C/C++ on a Window or *nix system where the compilers are of high quality, nobody gets hurt. </p>
  
  <p>If you're using a low quality compiler or an interpreted environment, you may need to be sensitive to this. Certainly, if you're doing advanced C++ or device driver or embedded work, hopefully you're well seasoned enough for this to be not a big deal at all. (Do dogs have Buddah-nature? Who really needs to know?)</p>