At work I’m integrating a library from our new corporate overlords into an existing application. I use 5 (count ’em, 5) functions from the library. In order to work, the library, which I’ll call libsink, requires between 10-20 other libraries, most of which appear to have nothing to do with the purpose of libsink I am using. This, to use a technical term, smells bad.
I probably wouldn’t care so much if I hadn’t discovered a symbol collision between the libraries on which our application is newly dependent and another library (libgoo) we use. Two different functions, two different libraries, with different semantics, but the same signature — meaning libsink will happily try to use the function from libgoo. Unfortunately, this results in a core dump when the application unloads.
So, if you’re writing libraries (especially in C, where there is only a global namespace):
- Please keep your dependencies to a minimum; why should I need code to perform higher order calculus in order to print something to the screen?
- If you’re going to write utility functions that may have names other libraries may use (like, say print() or open()), prefix the function with a string to uniquely identify it and prevent users from accidentally using the wrong function.