Too many software libraries require that you manually initialize them before use. As illustration:
library.initialize() window = library.createLibraryObject()
Why require your users to remember initialization busywork? createLibraryObject should initialize the library, refcounting the initialization if necessary.
The primary benefit is cognitive. If a library requires initialization, its objects and functions have an additional, externally-visible behavior: “If not initialized, return error.”
If the library’s internal state is managed implicitly, it does not leak out of the API. createLibraryObject should lazily initialize the library on object construction. Optionally, on object destruction, it can deinitialize the library.
A secondary benefit of lazy initialization is performance: interactive desktop applications rarely need immediate access to all of its subsystems. By deferring as much initialization as possible, application startup time is reduced.
[This post is a test of my new host: prgmr.com]