News for hackers. Stuff that matters.
Re:Transmission torrent client ported to C++ by userbinator on Sunday September 12, 2021 @05:31PM (#28505186)
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.

Re:Transmission torrent client ported to C++ by stjohnswarts on Sunday September 12, 2021 @07:53PM (#28506306)
Unless 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.
Re:Transmission torrent client ported to C++ by hoseja on Monday September 13, 2021 @02:43AM (#28508486)
Are you actually being serious? Less than 3% increase warrants such a reaction?
Re:Transmission torrent client ported to C++ by userbinator on Monday September 13, 2021 @09:24AM (#28511166)
Will it ever decrease by 3%?

The amount of increase is irrelevant if it continues in the same direction.

Re:Transmission torrent client ported to C++ by rwmj on Sunday September 12, 2021 @05:41PM (#28505269)
A 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?
Re:Transmission torrent client ported to C++ by bregma on Sunday September 12, 2021 @07:08PM (#28505939)
libstdc++.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.

Re:Transmission torrent client ported to C++ by password4321 on Sunday September 12, 2021 @08:25PM (#28506523)
I 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-952350...

> The increase in bundle size is significantly small (~10MB).

Re:Transmission torrent client ported to C++ by 10000truths on Sunday September 12, 2021 @06:52PM (#28505792)
That 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>.
Re:Transmission torrent client ported to C++ by pjmlp on Monday September 13, 2021 @02:29AM (#28508404)
Here, targeting Commodore 64 with C++17.

https://www.youtube.com/watch?v=zBkNBP00wJE

Re:Transmission torrent client ported to C++ by kevindong on Sunday September 12, 2021 @08:46PM (#28506648)
100k bytes = ~98 KB.

That's not material.