blog dds

2005.07.15

C++0X Enhancement: Packaged Libraries

In a recent article Bjarne Stroustrup presented the evolution of C++ toward the 0X standard, and asked the C++ community for ideas regarding C++ enhancements. This is a proposal to add to C++ support for using packaged libraries, and a standardizing a library distribution format.

Consider a typical list of enhancements to the C++ libraries. Such a list could contain: a matrix data type, a graph data structure, image manipulation classes, a networking API, cryptography, GUI programming, sound processing, compression, a currency data type, and an arbitrary precision arithmetic library. We can then generalize this list into the following requirement: provide all useful elements available in the union of the Java 5 platform, Perl's CPAN modules, the PHP libraries, and so on. Of course, neither the initial list, nor its generalization stand much chance to affect C++0X. A more realistic solution would be to provide a platform for adding these facilities, and then leveraging the work of the open source community (like Boost) for the actual library implementations.

There are two requirements for providing the C++ community with a successful library repository: the standardization of the library distribution format, and some minimal support for using packaged libraries in C++ programs.

The standardization of the library distribution format should address the following issues:

  • naming of packages,
  • naming of namespaces,
  • versioning,
  • layout of the package contents (manifest, directory and file names), and
  • package format (serialization and compression).
Elements that are probably not ready for standardization are: code licenses, the availability of non-compiled resources (for example, text, fonts, graphics), compiled distribution formats, caching, the installation and distribution of the libraries, automatic fetching, and the facilities for using shared (dynamically linked) libraries. All elements but the first two ones are quality of implementation issues. Given a library distribution standard, different implementations can address these issues in different ways, without jeopardizing the portability of packaged libraries. To be portable libraries should be distributed in source-code form. This requirement is not a problem for open source implementations. For commercial vendors the risk of exposing proprietary information can be somewhat mitigated by code obfuscation technologies.

The linguistic support for using a packaged library in a program should be minimal. A preprocessor directive like

#import libraryname [version-specification]
should be enough. The directive would make available to the compilation unit the facilities of the named library, and arrange for the library code to be linked with the final executable image. It is up to the specific C++ implementation to compile the library's source code to ensure ABI compatibility with the rest of the program, cache compiled versions of the libraries, and utilize shared library facilities where available. The optional version-specification element of the directive could be a list or a range of library versions that the specific compilation unit can work with. It would be reasonable to restrict each linkage unit to the use of a single version of a library.

Read and post comments    AddThis Social Bookmark Button


Creative Commons License Last modified: Wednesday, July 20, 2005 1:19 pm
Unless otherwise expressly stated, all original material on this page created by Diomidis Spinellis is licensed under a Creative Commons Attribution-Share Alike 3.0 Greece License.