Subj : OO compilers and efficiency To : comp.programming From : Brian Date : Tue Jul 19 2005 04:15 pm Is there a good approachable book that covers OO compilers? Something like a Red Dragon for the ages? OO seems like it must be very wasteful. Extending a class usually means taking the super class' existing method and tacking on some new secret sauce stuff. So is this wrapping one stack frame on top of another? First the subclasses method gets called then super's? Are compilers generally smart enough to inline the two calls into one? Getter and setter functions are another simple example of what seems to be waste. The method call works like this. The existing register states are pushed onto the stack. The call is made. The getter method returns a simple value on the stack. The call is returned. The registers are popped. That must be about 20 instructions for what might only take one, a simple memory read, or better yet, a register read. What happens if a getter or setter is right in the middle of a tight loop? Let's say the loop has 200 instructions. All of a sudden the loop is 10% less efficient. I guess it could be argued that this has other penalties. The stack frames may be forcing unnecessary cache movement or invalidating CPU pipeline flow. Anyway, those are some of the things that kind of nag at me. I think it's a safe statement to say C can beat any OO compiled program pound for pound given the same programmer skill and adherence to language goals. Does everyone drop into C for critical code? Or am I the only one who worries about this stuff? Is it a concern or should I kind of push it back into the recesses of my mind and say the wastefulness is part of the tradeoff for programming OO code? Thanks for reading. .