
Mike Acton's "Typical C++ bullshit" - malkia
http://macton.smugmug.com/gallery/8936708_T6zQX/1/593426709_ZX4pZ#593426709_ZX4pZ
======
corysama
To put this in perspective: When Mike talks about this stuff, he's coming from
a position of "This is serious business. The point of my job is to make this
run 10,000 times in 0.1 milliseconds. It can be done. It's not that hard. Why
are you screwing up simple stuff like this?" The code he was reviewing was
inner-inner-inner-loop, performance critical logic. That stuff doesn't always
spring fully-formed from the standard library. Sometimes you have to write it
yourself. When its your turn, it would be worth heeding the advice of someone
like Mike -who has spent a good part of his career figuring out how to do it
well.

As for the arrogance... I've seem Mike speak live on this topic. He hams-up
the attitude because it gets a reaction from the audience. He's trying to
irritate you into improving yourself. To his discredit, very little of what he
is complaining about has much to do with C++.

------
scott_s
The comment "Why are you writing to a member in an inner loop? Use a local in
a register. Why make the compiler guess at something you know?" is misguided.
Simply, why muddy-up your own code when the compiler will probably do the work
for you? Your time is valuable. The compiler won't complain if you make it
work a little bit more.

~~~
malkia
Yes, it would. But this comes from a game developer, being one myself - we
often need DEBUG builds that are relatively fast, because you develop your
game mostly in such build (well not real DEBUG, but almost). For that reason,
anything you can do help the compiler even if it's not optimizing is good.

For example overriding operators such +, -, for say matrices/vectors might
seem good idea (off course inlined, etc.) - but in DEBUG it creates such
overhead, especially if it's nested. Instead use simple function call.

Check Mike's page (cellperformance.com) - <http://www.cellperformance.com/>

~~~
scott_s
I do high performance systems research - half of the time using the Cell,
coincidentally - and I've learned to just write straight-forward, idiomatic
C/C++ as much as possible. I'd only perform the kind of optimization the
author suggests if I knew for sure that code was my bottleneck.

------
antipax
Wouldn't 99% of this stuff be cleared up by the compiler anyway?

~~~
malkia
It would, or it might, but there are edge cases where it won't, and it's good
to give the rights hints to the compiler (and then again every compiler is
different).

[http://www.cellperformance.com/articles/2006/04/programming_...](http://www.cellperformance.com/articles/2006/04/programming_with_branches_patt.html)

Though my favourite article from his site is this one:

[http://www.cellperformance.com/articles/2006/06/box_overlap....](http://www.cellperformance.com/articles/2006/06/box_overlap.html)

------
huhtenberg
Arrogant.

