Hacker News new | ask | show | jobs
by filipdobro 3 days ago
> Dependency friction in C++ is so punishing that authors advertise “header-only, zero dependencies!”

This article kinda sums up all frustrations I have with C++. Vcpkg seemed like a good fix at the time, but it needs so much more improvement and adoption.

A lot of good solutions to the raised issues in the article require us to rip the bandaid off, however I believe the community built around C++ has built their systems around the premise that it must remain stable and predictable.

7 comments

I can not express how disinterested I am in using a Microsoft Visual C++ package manager. There will always be a large contingent of C++ users who won't touch vcpkg with a 10 foot pole.

Anyway I don't understand the aversion to just using submodules. What we need is a decent standard build system, not a package manager. We have CMake which is wide-spread but garbage, and we have Meson which is pretty good but not as widely adopted. If every library had a meson.build file I'd be mostly happy with just having submodules to them in my subprojects/ dir.

> Anyway I don't understand the aversion to just using submodules.

The reason is highlighted in the article: Submodules break down catastrophically for shared transitive dependencies, which means that you can't have shared "vocabulary" types outside of the standard library.

No they don't? You just add the shared transitive dependency as a submodule in the top-level project and express in the build system that it's a dependency in the library's meson.build.

As a significant bonus, this makes the transitive dependencies very visible and provides ecosystem pressure for libraries to reduce their number of dependencies. This is a good thing. Other package management schemes make it a bit too easy to ignore transitive dependencies in my book.

I'm sure you can see how that doesn't scale without significant effort. Stuff like this is why dependency management in large C++ projects is extremely draining. And if you don't get it right, boom, ODR violation = UB.

The end result is that many C++ projects spend a huge amount of time whenever a dependency is added or updated, so they tend to avoid it and lag behind, leaving performance and bugfixes on the table.

Meanwhile, Cargo even supports linking multiple versions of the same dependency without issue in the same binary. It is lightyears ahead.

Sure, it doesn't scale to your typical node.js project with thousands of dependencies. That's a good thing.
ffmpeg has 100+ transitive dependencies. I don't see what language or language package managers have to do with the number of transitive dependencies.
"it's not a bug, it's a feature"
Classic sour grapes.
> Microsoft Visual C++ package manager

vcpkg is certainly created and maintained by Microsoft.

But it is not for Visual C++. Visual Studio build tools is supported, and it's the default (but not only option) on Windows. But it supports other platforms and build tools too.

The "vc" in "vcpkg" stands for Visual C++.
Because that is where it was born, and the team that owns the project.
And it means it's completely uninteresting in my eyes.
Nowadays that will cut out plenty of open source projects, given Microsoft sponsorship.
The Conan package manager is cross-platform and just what the doctor ordered for C/C++.

https://conan.io/

I still don't see why I would want it. Any project which includes a meson.build is super easy to just add as a submodule.
> We have CMake which is wide-spread but garbage, and we have Meson which is pretty good but not as widely adopted

If it works for you use it. Just because meson looks very usable to you, it does not mean others have to adopt its opinionated bullshit and irrelevant approach.

Meson and Cmake are both there to solve user's problem, not expose users to all their dirty laundry dressed up as 'design approach'. Since both have their bullshit buckets full, it just depends on user's familiarity and personal preferences.

I dislike Cmake, and many years ago I watched videos of Pakkanen about build system design, and was impressed on what the video was conveying meson could do. Then I tried to implement meson on a firmware project. The project was still evolving, and the kind of babysitting and project reorg I had to do to pacify meson was more than the language bullshit that I had to deal with cmake. cmake has generator expressions and interfaces, so one could easily build for say stm32 and posix target with the same project tree. meson, if i remember, does not allow such config.

Long story short, went back to cmake, and with llm it is not even an issue. meson would be a non issue with llm too, but what surprised me the most was the theory of the videos by Pakkanen and the impl bullshit one had to deal with Meson on twisting the project into meson's well-of-wisdom. That might be one of the reasons why nobody adopts meson.

> what we need is a decent standard build system, not a package manager

These are the same thing and the more you reject it the more you suffer

Well they're not. Maybe they should be but they're not.

In JavaScript, NPM is a package manager. Build systems (Vite, Webpack, Browserify, ...) are separate.

In C++, we have vcpkg and Conan. Both are package managers, neither are build systems. I haven't used vcpkg but at least Conan integrates with Meson, CMake and other build systems.

A good build system (i.e not Make) has a clean concept of what a "package" is and how the dependencies between "packages" work. But a build system does not need to know how to download packages, it just needs to know what to do about them once it's pointed at a package. The problem with Conan is that it has to support a bunch of different build systems, so the definition of what a "package" is gets muddied.

This is "the more you reject it the more you suffer" part

CMake and Meson both support package management. Conan also is a build system as much as a package manager. NPM is a build system, too. The degrees to which they try to pass off responsibility to other tools is why they suck.

> a clean concept of what a "package" is

First mistake: assuming you can define this. Good build systems/package managers don't define this at all, nor should they. It's natural for software developers to want to put limits here and try and box things in but it just makes life harder for everyone.

A build system orders individual operations that take inputs and yield outputs. That's it. This is what Make got right.

Package management is just an extension of that.

> a build system does not need to know how to download packages

Downloading is trivial. The actual package management part is checking hashes, version unification, and handling updates.

There's just no argument to me that these need to be separate tools, when bad tools wind up doing the same work poorly.

Vcpkg solved most of my problems in a windows env - vs+msbuild+vcpkg in manifest mode. It is also not really intrusive, just one json file. Auto link is very useful. I am very happy when I see a dependency is available via vcpkg.
Unfortunately, vcpkg is not (in practical sense) available for operating systems, it's a windows-only solution.
Wrong. It works on all major OS, even for Android.
I stand corrected.

Having said that, homebrew also works on Linux, etc. It doesn't make it a solution even remotely. Like, using homebrew on Linux or vcpkg on non-windows sounds like a winning combination of flaws conveniently packaged.

I'd claim it works better on Linux. But depends on what kind of packages you use, I guess.

And it was a separate installation from Visual Studio for a long time as well.

I do manage a build cluster for Windows/macOS/Linux and I have to manage a bunch of dependencies built in a plethora of different ways and configurations on all three platforms.

It's still hell. And vcpkg is definitely not the hottest place in it.

Works perfectly fine on Linux. I use it on multiple platforms, no bother.
You are the second person to tell me it's nice on linux.

Seems I should actually give it a try. Thanks!

Vcpkg was really hurt by skipping a release, without any communication, even ignoring tickets. We thought that our single source of dependencies was silently killed.
My only pain point with vcpkg is the team's reluctance, or lack of resources (in a 4 trillion valued company(!)), to make the experience at least as nice as using NuGET, across VS and VSCode.

Note that Clion does exactly this for vcpkg.

I use Spack, from my academic years.
Yeah, and where are all these zero dependencies libraries that implement TLS, JWT handling, Database Connection? Are here with us?