Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Are there any particularly good books for understanding how C++ works "under the hood"? My reasons for asking this are that I am very interested in C++ performance system programming (low latency etc).

I have been suggested the following but wasn't sure if there are any others:

  • C++ FAQs
  • Modern C++ Design
  • Effective C++

Basically I dont want books which are going to teach me the C++ syntax, but rather if I create this object, this is what really happens and this is achieved via this part of the operating system bla bla etc.

An example of something I recently learnt and would like to learn more similar interesting facts: if you inline C++ code too much, you will increase the program instruction size, the number of OS pages it occupies and this will increase the likelihood of TLB misses for the processor.

share|improve this question

closed as not constructive by gnat, Doug T., BЈовић, World Engineer, William Shakespeare May 11 '12 at 16:31

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

    
See here stackoverflow.com/questions/388242/… –  Doug T. May 11 '12 at 13:50
    
Sounds to me as if you were asking for some knowledge which can become very quickly obsolete with the next version of your favorite compiler, by changing some optimizer flags or by having a new version of your processor hardware. –  Doc Brown May 11 '12 at 14:09
1  
"Modern C++ Design" is definitely not what you want: the book is amazing to the point of being mind-blowing, and it will expand your programming horizons enormously, but it is not about the "under the hood" details. Prior exposure to non-imperative programming languages is very useful if you are to attempt this book. –  dasblinkenlight May 11 '12 at 14:37
    
I've seen such a book, but unfortunately can't recall the title :( –  Crazy Eddie May 11 '12 at 15:32
1  
Inside The C++ Object Model by Stanley Lippman covers most of what you seem to be after. –  Jerry Coffin May 11 '12 at 16:45

3 Answers 3

You'll have a hard time finding books that go into how the operating system is used in C++, because the language itself is operating-system independent. However for the kinds of things you seem to be interested in I have a recommendation that isn't in the answer to the linked other question:

Efficient C++ by Dov Bulka and David Mayhew

It goes into some typical performance gotchas in C++ such as time taken in constructors, possibly unexpected temporaries etc.

It may be slightly out of date now with C++11, but I know that it helped me get a firm grasp of some areas to pay attention to when performance matters.

share|improve this answer
    
Ah that was the book I came across on amazon a few months ago but struggled to find it. Would you say it's still worth it aside from c++11? Are most of the C++11 new features something which a low latency programmer would avoid, because they are bloaty "friendlier" introductions? –  Roger May 11 '12 at 16:42
    
@Roger - some of the C++11 features are specifically for high-performance (low latency) programmers (i.e. rvalue references) - and these are not covered in the book. However if you can spare the cash I think it's still worth getting and reading because it covers pretty much everything before C++11, and that hasn't gone away. –  Joris Timmermans May 14 '12 at 7:34

if I create this object, this is what really happens and this is achieved via this part of the operating system

Honestly, if you want to know that (which is specficially to the compiler and the optimizing level you are using), write a small program, compile it and use a disassembler to look what the compiler generates from it. Some IDEs or compilers have a possibilty to display you the C++ statements side by side to the assembler instructions.

share|improve this answer

The Design and Evolution of C++ is a bit old, but it describes in detail the decisions going in to the design of the language, and this directly includes many performance considerations. It isn't going to tell you anything about how this affects different processors directly, but can be used to derive that. For example, if you understand that templates work by code replacement, you'll understand why they can bloat code, which can lead to cache misses.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.