So, in concrete practical terms, what harm do singletons do?
The harm comes from limitations built into classes that don't belong there.
A class should not know or care how many instances of it exist. If your program only needs one instance of an object, then that is part of the business logic of the program. Singletons make the sweeping assumption that nobody will ever need more than one of these. These kind of assumptions bite you in the ass in the long run.
sure, you can just put the interface in the header file and have all the data declared statically in the source file, but then you've got that data sat around in memory the whole time. You have to work harder to allocate, initialise and delete stuff because you don't have a constructor or a destructor, and as Klaim pointed out, control over when and how singleton data is created and destroyed can be pretty important.
This is simple. You create an internal structure in the implementation file, and allocate it when needed. Provide Setup and Teardown calls in your module, call them at the beginning and end of the module's usage.
This is actually less
code than the traditional singleton implementation. You only need to call Setup once, as opposed to calling get_instance or whatever every time you want the functionality. The call to Teardown mirrors the call to delete the singleton instance (you are deleting it, right?). This problem was solved long ago by procedural languages. Singleton puts an unnecessary object-oriented spin on the traditional procedural module.
Further, most singletons (at least the ones I've seen) are active for pretty much the entire run of the program anyway. Their data is basically sitting around in memory the whole time as is.
And just in case, because this has happened before, just because you only happen to have one instance of something in your program does not
make it a singleton. I have no beef with this. A singleton is a class that actively prohibits the existence of more than one instance. Some people don't understand the difference and completely misunderstand my points, thinking I'm criticizing something else.