5 ms·
I haven't really touched C++ for a few years and it seems due to its lack of a nice package manager single header libraries are getting more and more poplar. Do
by HMH 5y ago
I haven't really touched C++ for a few years and it seems due to its lack of a nice package manager single header libraries are getting more and more poplar. Does this mean I should expect compilation time to significantly increase during development as headers need to be recompiled every time?
- pjmlp 5y agoIn the meantime two big contenders raised up, vcpkg alongside NuGET from Microsoft (also does Mac and Linux), and conan. Personally I dislike conan, because package managers should be written in the language of the community they serve, but that is me. Thankfully, both support binary libraries. Then there are modules, which on Visual C++'s case are going along quite well. Anyone that bothers using header only libraries only has themselves to blame for waiting for builds, they are a plague from users that pretend C and C++ are scripting languages.
- ngneer 5y agoConan has been very useful to me
- twqas 5y agoUnfortunately Microsoft is addicted to telemetry, so vcpkg has that. I did not bother checking for NuGET. Header-only libraries can give substantial speedups (25% in extreme cases).
- pjmlp 5y agoYou can disable it. I really would like to see benchmarks versus proper use of binary libraries.
- inetknght 5y ago> You can disable it. I shouldn't have to think about it; I shouldn't have to explicitly opt-out to have privacy. Telemetry should always be opt-in, and not opted-in by default.
- ranger_danger 5y agoThe problem is, as a developer trying to fix issues, telemetry can be extremely helpful... but if it's solely opt-in, then virtually nobody will actually use it, and then what's the point.
- kjs3 5y agoSo your developer issues should trump my user issues?
- TillE 5y agoIt tells you to just recompile with -disableMetrics if you want, it's really not a huge deal. It's not like Windows.
- kjs3 5y agoSo as a user, I have to recompile in deference to making things easier for the developer. Definitely not like Windows...for all their sins, they don't pull entitled BS like that on users.
- jstimpfle 5y ago"Header only" might be a bad name, in my perception what it really means is "you can drop the code files into your project; we won't annoy you with our own over-engineered build system". Slow-compiling APIs can be made in any form, whether "header only" or not. C++ template APIs cannot be compiled separately and can cause long compile times for all transitively dependent translation units. For example, stb_image.h is a single file that is 1 copy+paste from github away. It compiles quite quickly, and often you will need it alongside only a single .c file in your project, but anyway it's extremely easy to compile it separately. All you have to do is cut+paste the implementation part to a separate .c file.
- pjmlp 5y agoTemplates can be instanted for common types and consumed via binary libraries. Also modules support templates just fine. Indeed, header only libs are just doing PHP like programming.
- moonchrome 5y agoCopy pasting shit in your repo means you are responsible for maintaining that code and need to keep track of upstream manually. Especially in c++ where memory bugs are prevalent, this sounds like a terrible idea.
- mrich 5y agoIn the case here most of the code is templates and macros, so a cpp wouldn't save much.
- ranger_danger 5y agoJust include that header in a separate C/C++ file that has no other purpose, then you won't have to recompile it every time you change something elsewhere.
- corysama 5y agoYeah. "header only" had really caught on because it is a catchy term that is simple to understand. But, what I really, really wish caught on would be "single cpp file" with the expectation that you are capable of adding a single, self-contained source file to whatever build system you happen to be using.
- electroly 5y agoThat's often what "header only" libraries really are -- you create your own .cpp file, define a particular preprocessor symbol, and then include the header which will then produce the implementation in that translation unit. Without the symbol defined you only get the interface, suitable for including in other translation units.