Bloat and runtime overhead
The term bloatware describes unwanted software that is preinstalled with an OS on a device. Unwanted software in the world of programming describes code inserted in a binary by a framework, a library, or a language construct itself. Language constructs in C++ that are blamed for causing code bloat are constructors, destructors, and templates. We will analyze these misconceptions by examining assembly output generated from C++ code.
Constructors and destructors
The first thing that comes to mind to non-C++ developers when you mention C++ is that it is an object-oriented language and that you are bound to instantiate objects. Objects are instances of classes. They are variables that occupy memory. Special functions, called constructors, are used to construct or instantiate objects.
Constructors are used to initialize objects, including the initialization of class members, and destructors are used to clean up resources. They are tightly tied to...