![](https://csdnimg.cn/release/download_crawler_static/9508999/bg12.jpg)
Then a funny thing happened. Processor cores stopped getting faster, but workloads
kept growing. Those same companies began hiring C++ programmers to solve their
scaling issues. The cost of rewriting code from scratch in C++ became less than the
cost of the electricity going into their data centers. All of a sudden, C++ was popular
again.
Uniquely among programming languages in wide use in early 2016, C++ offers devel‐
opers a continuum of implementation choices, ranging from hands-off, automated
support to fine manual control. C++ empowers developers to take control of perfor‐
mance trade-offs. This control makes optimization possible.
There are not many books on optimization of C++ code. One of the few is Bulka and
Mayhew’s meticulously researched but now somewhat dated Optimizing C++. The
authors appear to have had similar career experiences to mine, and discovered many
of the same principles. For readers who are interested in another take on the issues in
this book, their book is a good place to start. Also, Scott Meyers, among many others,
covers avoiding copy construction extensively and well.
There are enough different things to know about optimization to fill 10 books. I have
tried to pick and choose things that seemed to occur frequently in my own work, or
that offered the biggest performance wins. To the many readers with their own per‐
formance tuning war stories who may wonder why I’ve said nothing about strategies
that worked miracles for them, all I can say is, so little time, so much to tell.
I welcome your errata, comments, and favorite optimization strategies at
antelope_book@guntheroth.com.
I love the craft of software development. I enjoy endlessly practicing the kata of each
new loop or interface. At the corner of Sonnet and Science, writing code is a skill so
esoteric, an art form so internal, that almost nobody but another practitioner can
appreciate it. There is beauty in an elegantly coded function, and wisdom in a power‐
ful idiom well used. Sadly, though, for every epic software poem like Stepanov’s Stan‐
dard Template Library, there are 10,000 drab tomes of uninspired code.
The root purpose of this book is to give every reader permission to think a little
harder about the beauty of well-tuned software. Take it and run with it. See farther!
Apology for the Code in This Book
Although I have been writing and optimizing C++ code for over 20 years, most of the
code appearing in this book was developed specifically for this book. Like all new
code, it surely contains defects. I offer my apologies.
I have developed for Windows, Linux, and various embedded systems over the years.
The code presented in this book was developed on Windows. The code and the book
no doubt show a Windows bias. The lessons of how to optimize C++ code that are
xvi | Preface