News for hackers. Stuff that matters.
Re:C++ for Games: Performance, Allocations and Data Locality by wmil on Monday May 30, 2016 @07:47AM (#11800825)
It just sets of my BS detector. Some people will think it's OK to lie to get others to use their prefered coding style.
Re:C++ for Games: Performance, Allocations and Data Locality by to3m on Monday May 30, 2016 @09:18AM (#11801154)
But it's not BS. If you could use one or the other, so this isn't "a[i++]" or whatever, you should always use the prefix version, particularly if you're operating on a non-primitive type.

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.

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.

Re:C++ for Games: Performance, Allocations and Data Locality by Retra on Monday May 30, 2016 @11:13PM (#11804326)
The only reason you'd have +EV is if evidence suggested it to be so. You compute EV using evidence, and if you don't have any evidence, you don't have any EV at all.