Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 615153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:11:21+00:00 2026-05-13T18:11:21+00:00

Personally, I quite like header-only libraries, but there are claims they cause code bloat

  • 0

Personally, I quite like header-only libraries, but there are claims they cause code bloat due to over-inlining (as well as the other obvious problem of longer compile times).

I was wondering, how much truth is there to these claims (the one about bloat)?

Furthermore, are the costs ‘justified’? (Obviously there are unavoidable cases such as when it’s a library implemented purely or mostly with templates, however I’m more interested in the case where there’s actually a choice available.)

I know there’s no hard and fast rule, guideline, etc as far as stuff like this goes, but I’m just trying to get a feel for what others think on the issue.

P.S. Yes this is a very vague and subjective question, I’m aware, and so I have tagged it as such.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T18:11:22+00:00Added an answer on May 13, 2026 at 6:11 pm

    I work for a company that has a “Middleware” department of its own to maintain a few hundreds of libraries that are commonly used by a great many teams.

    Despite being in the same company, we shy from header only approach and prefer to favor binary compability over performance because of the ease of maintenance.

    The general consensus is that the performance gain (if any) would not be worth the trouble.

    Furthermore, the so called “code-bloat” may have a negative impact on performance as more code to be loaded in the cache implies more cache miss, and those are the performance killers.

    In an ideal world I suppose that the compiler and the linker could be intelligent enough NOT to generate those “multiple definitions” rules, but as long as it is not the case, I will (personally) favor:

    • binary compatibility
    • non-inlining (for methods that are more than a couple of lines)

    Why don’t you test ? Prepare the two libraries (one header only and the other without inlining methods over a couple of lines) and check their respective performance in YOUR case.

    EDIT:

    It’s been pointed out by ‘jalf’ (thanks) that I should precise what I meant exactly by binary compatibility.

    2 versions of a given library are said binary compatible if you can (usually) link against one or the other without any change of your own library.

    Because you can only link with one version of a given library Target, all the libraries loaded that use Target will effectively use the same version… and here is the cause of the transitivity of this property.

    MyLib --> Lib1 (v1), Lib2 (v1)
    Lib1 (v1) --> Target (v1)
    Lib2 (v1) --> Target (v1)
    

    Now, say that we need a fix in Target for a feature only used by Lib2, we deliver a new version (v2). If (v2) is binary compatible with (v1), then we can do:

    Lib1 (v1) --> Target (v2)
    Lib2 (v1) --> Target (v2)
    

    However if it’s not the case, then we will have:

    Lib1 (v2) --> Target (v2)
    Lib2 (v2) --> Target (v2)
    

    Yep, you read it right, even though Lib1 did not required the fix, you head to rebuild it against a new version of Target because this version is mandatory for the updated Lib2 and Executable can only link against one version of Target.

    With a header-only library, since you don’t have a library, you are effectively not binary compatible. Therefore each time you make some fix (security, critical bug, etc…) you need to deliver a new version, and all the libraries that depend on you (even indirectly) will have to be rebuilt against this new version!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Personally I like this one: P.S. Do not hotlink the cartoon without the site's
Personally, I've found that when good developers deal with clients, they often get sucked
I personally like the exclusive or , ^ , operator when it makes sense
I'm working with quite a big codebase which compiles fine in linux but vc++
I started learning Rails only a few days ago, but in the mean time
Personally, I find the range of functionality provided by java.util.Iterator to be fairly pathetic.
Personally I really prefer Unit Testing and write them for good coverage. (let's say
I personally don't use FxCop yet. We want to work out the unit testing
I personally used Mercurial and Subversion in a limited way and I just can't
I personally loathe background music on a website. My client has opposite feelings on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.