Re:C++ for Games: Performance, Allocations and Data Locality
by gruez on Monday May 30, 2016 @10:01AM
(#11801381)
> just that choosing ++it is +EV
Sounds like pascal's wager
Re:C++ for Games: Performance, Allocations and Data Locality
by Retra on Monday May 30, 2016 @02:17PM
(#11802402)
Pascals Wager is about assuming the EV is infinite, not that it simply exists.
Re:C++ for Games: Performance, Allocations and Data Locality
by gruez on Monday May 30, 2016 @02:39PM
(#11802485)
That's why I said "like". They're both in that you're choosing the option with the +EV rather than the one that the evidence points to.
Re:C++ for Games: Performance, Allocations and Data Locality
by mikeash on Monday May 30, 2016 @04:34PM
(#11803020)
The error in Pascal's Wager is assuming there are only two possibilities. Once you realize that there's the possibility of a God who, say, punishes all the faithful, the argument falls down.
That's not the case here. There are actually only two alternatives.
Assuming the two are written sensibly, and you don't have a Sleep(1000000) in your prefix version or something, the best case is that the two perform the same. The worst case is that the compiler can't spot that the result of the postfix version can be ignored, and the postfix version is then a bit less efficient.
I'm not saying this is likely to end up being the bottleneck in your program... just that choosing ++it is +EV.
I suspect lots of people use it because they learned it that way and now it's been blah blah blah years and it's too late to change. But for some reason, they don't want to admit this, so they come up with spurious reasons for changing being the wrong thing. Which is odd, because when the two would be equivalent, force of habit is basically the only good reason to prefer it++ over ++it.