Have Your Efficiency, and Flexibility TooMetaprogramming Techniques For No-Compromise Codeby Nick SabalauskyFull source code for this article is available on GitHub, or can be downloaded here. View this article on a Single Page or Table of Contents:
Curtain CallAlthough the examples throughout this article have focused on situations with large numbers of simplistic objects, these techniques can also work very well with smaller numbers of objects that do a lot of processing. The templated versions of UltraGiz give just a small glimpse of this. We've seen that you can use metaprogramming with structs to achieve much of the same flexibility as classes while avoiding the class overhead. But even if you do go with classes, these metaprogramming techniques can still aid in optimization without forcing you to cut features and give up flexibility. Ok, so towards the end we did start running into more tension between efficiency and flexibility. Perhaps those wacky nuts will never fully resolve their differences. But even so, they've made some major progress. Whenever you have values or settings that don't need to change, you don't have to choose between eliminating them for efficiency and keeping them for flexibility. You can have both, with no compromise. And even if your values and settings do need to change, but just not constantly, you still have many options available for getting your efficiency and flexibility to cohabitate peacefully. So go ahead, use metaprogramming to have your efficiency, and flexibility too. Thanks to Lars T. Kyllingstad, bearophile and Timon Gehr for their suggestions. Table of Contents:
|