Suppose you have a program in C, C ++, or any other language that uses the "compile-objects-then-link-them" scheme.
If your program is small, it can compromise several files to simplify code management (and reduce compilation time). Also, after a certain degree of abstraction, you probably have a deep hierarchy of calls. Especially at the lowest level, where the tasks are most repeatable, most often you want to impose a common structure.
However, if you fragment your code in different object files and use a very abstract architect for your code, this can lead to increased productivity (which is bad if you or your manager emphasize performance).
One way to get around this can be with extensive inlining - this is the metaprogramme approach of the template: in each translation module, you include all the code for your common, flexible structures and rely on the compiler to counter performance problems. I want to do something like this without templates - say, because they are too difficult to handle, or because you are using simple C.
You can write all your code in one file. That would be terrible. How about writing a script that combines all of your code into a single source file and compiles it? Requiring your source files not to be written too wildly. Then the compiler would probably apply much more optimization (embedding, enameling dead code, compile-time arithmetic, etc.).
Do you have experience or objections to this "trick"?
source
share