3 ms·
Thanks for the proof. Over 100k increase on average. Not surprising. ...and people wonder why software gets slower and bigger over time while doing the same th
by userbinator 5y ago
Thanks for the proof. Over 100k increase on average. Not surprising.
...and people wonder why software gets slower and bigger over time while doing the same thing. We even get HN articles about that semi-regularly.
- rwmj 5y agoA question that I'd like to ask a C++ expert: If you use any STL container, is it always the case that the whole thing is templated, therefore effectively compiled and statically linked into the binary? Or will part/all of it come from functions in the dynamically linked libstdc++.so?
- deleted 5y ago[deleted]
- 10000truths 5y agoThat depends on how the standard library is implemented. I wouldn’t be surprised if libc++ or libstdc++ used explicit template instantiations for STL containers of primitive types, e.g. std::vector<int>.
- bregma 5y agolibstdc++.so (and libc++.so if you're bent that way) contain the standard stream objects, some standard string functions specialized on `char`, some threading and synchrony support and important parts of the C++ language runtime (eg. a default ::operator new, some of the exception unwinding and RTTI mechanisms). And that's it. It's actually fairly small and basic. Pretty much everything else in the C++ standard library is template code in headers and gets instantiated when needed. You may end up having identical templated functions emitted into several different translation units and the linker will chose one at link time, which is one major reason why C++ is slower to build. Only template functions that are actually used get instantiated. If you include a header with a gazillion templated functions (namespace level or member functions, it doesn't matter) you are most likely to end up with only one or two instantiated in your binary. Templates are like a cookbook, and just because Larousse has 10,000 recipes does not mean that's how much you're going to eat at every meal. Consider there is virtually an infinite number of possible instantiations for every template.
- password4321 5y agoI guess it depends on your definition of small... VSCode recently mentioned a 10MB hit to statically link the libcxx library from Chromium to dodge issues running on older platforms. Edit: libcxx from Chromium, not libstdc++ https://github.com/microsoft/vscode/pull/129360#issue-952350369 https://github.com/microsoft/vscode/pull/129360#issue-952350... > The increase in bundle size is significantly small (~10MB).
- stjohnswarts 5y agoUnless you're on a limited embedded platform 100k of size increase in a binary is basically nothing these days or any pc/mac built in the past 20 years. Also equating bigger to slower in binaries as a truism is usually a fallacy.
- kevindong 5y ago100k bytes = ~98 KB. That's not material.
- pjmlp 5y agoHere, targeting Commodore 64 with C++17. https://www.youtube.com/watch?v=zBkNBP00wJE https://www.youtube.com/watch?v=zBkNBP00wJE
- hoseja 5y agoAre you actually being serious? Less than 3% increase warrants such a reaction?
- userbinator 5y agoWill it ever decrease by 3%? The amount of increase is irrelevant if it continues in the same direction.