Consider the Hardware

From WikiContent

Jump to: navigation, search






Inline functions are a different animal that trades requiring start up and completion tasks for overall program size. The word inline is accurate because everywhere in your source code where you have a call to an inline function, the code for that function is copied into your code verbatim and then it is compiled. Having too many inline functions, especially large ones, can significantly increase your compiled application's filesize; this might be a worthwhile trade. Speed or Filesize? Make your choice!

Depending on your compiler, there can be implications on program execution speed using classes. Many developers seem to think having class libraries that contain many generations of inheritance is wonderful when it comes at a price. Normal inheritance levels incur some overhead if you get into the nuts and bolts of them but the real problem when it comes to efficiency is those nasty virtual functions. Virtual functions require a virtual base class lookup table for each level of virtual inheritance and matters can get exponentially worse when there are multiple levels of inheritance. There are better things your processor could be doing than traversing memory linked list tables to hunt for code to run.

What hardware are you developing for? What does your compiler do to your code as it turns it to assembly language? Are you using a virtual machine? You'll rarely find a single programming methodology that will work perfectly on all hardware platforms, real or virtual.


By Jason P Sage

This work is licensed under a Creative Commons Attribution 3

Back to 97 Things Every Programmer Should Know home page

Personal tools