Alex Rivera | Logout

Does using large libraries inherently make slower code?

Asked 2010-02-11T20:23:53.170
50

I have a psychological tic which makes me reluctant to use large libraries (like GLib or Boost) in lower-level languages like C and C++. In my mind, I think:

Well, this library has thousands of man hours put into it, and it's been created by people who know a lot more about the language than I ever will. Their authors and fans say that the libraries are fast and reliable, and the functionality looks really useful, and it will certainly stop me from (badly) reinventing wheels.

But damn it, I'm never going to use every function in that library. It's too big and it's probably become bloated over the years; it's another ball and chain my program needs to drag around.

The Torvalds rant (controversial though it is) doesn't exactly put my heart at ease either.

Is there any basis to my thinking, or am I merely unreasonable and/or ignorant? Even if I only use one or two features of a large library, by linking to that library am I going to incur runtime performance overheads?

I'm sure it depends too on what the specific library is, but I'm generally interested in knowing whether large libraries will, at a technical level, inherently introduce inefficiencies.

I'm tired of obsessing and muttering and worrying about this, when I don't have the technical knowledge to know if I'm right or not.

Please put me out of my misery!

Edit
Report

1 Answer

4

The term I like for frameworks, library sets, and some types of development tools, is platform technologies. Platform technologies have costs beyond impact on code size and performance.

  1. If your project is itself intended to be used as a library or framework, you may end up pushing your platform technology choices on developers that use your library.

  2. If you distribute your project in source form, you may end up pushing platform technology choices on your end users.

  3. If you do not statically link all your chosen frameworks and libraries, you may end up burdening your end users with library versioning issues.

  4. Compile time effects developer productivity. Incremental linking, precompiled headers, proper header dependency management, etc., can help manage compile times, but do not eliminate the compiler performance problems associated with the massive amounts of inline code some platform technologies introduce.

  5. For projects that are distributed as source, compile time affects the end users of the project.

  6. Many platform technologies have their own development environment requirements. These requirements can accumulate making it difficult and time consuming for new developers on a project to be able to replicate the environment needed to allow compiling and debugging.

  7. Using some platform technologies in effect creates a new programming language for the project. This makes it harder for new developers to contribute.

All projects have platform technology dependencies, but for many projects there are real benefits to keeping these dependencies to a minimum.

answered 2010-02-12T02:26:59.513

Your Answer