2 ms·
There's no standard build system. Think about how you add a dependency in Rust, Go, JavaScript, even Python. Now do it in C/C++. Absolute nightmare. Look at h
by IshKebab 4y ago
There's no standard build system. Think about how you add a dependency in Rust, Go, JavaScript, even Python.
Now do it in C/C++. Absolute nightmare.
Look at how many header-only C++ libraries there are out there. They're making compilation time drastically worse purely to avoid the need to faff with a shitty build system. It's a good trade-off too. I use header-only libraries where possible. They're convenient and popular.
Actually vcpkg seems to be going some way to fixing that but I have yet to convince my co-workers to use it.
- JohnFen 4y ago> to avoid the need to faff with a shitty build system. Then maybe don't use a shitty build system? It's true, C is not trying to be a programming environment or tech stack. It's a language, that's it. Whether or not that's desirable depends on what you're trying to do, it's not something that is good or bad in some absolute sense. You have your choice of build systems, so pick one that meets your needs. Vcpkg isn't for me, either, because it doesn't solve any problem I have. If it does for you, awesome!
- IshKebab 4y ago> You have your choice of build systems, so pick one that meets your needs. And can I pick the one that my dependencies use too? Didn't think so.
- JohnFen 4y agoYour dependencies have already been built. You're just linking to them. So yes, you can.
- inferiorhuman 4y agoAnd what if the dependencies haven't been built yet?
- icedchai 4y agoBuild them and install them in /usr/local, just like we did 30 years ago.
- inferiorhuman 4y agoWith what? The whole point of this line of discussion is that building stuff in C is suboptimal, often requiring the end user to juggle n different build systems by hand to get all the dependencies installed. Since we're talking FreeBSD here, thirty years ago we had Modula-3 whose build system is lightyears ahead of anything make based.
- icedchai 4y agoYou already answered your own question: with whatever tools that dependency requires, often ./configure && make && make install In the event you find yourself doing this constantly, write a shell script.
- inferiorhuman 4y agoAnd now we're back at: this is why C is more difficult, for no good reason, than the alternatives. For small projects that you're only building locally, your approach may work. Once you expect any sort of cross-platform compatibility and/or start distributing your project to others, this approach falls apart and fast. Instead of focusing on development you'll be focusing on playing whack-a-mole with incompatibilities between the different shells (or versions of make, etc.) offered on different operating systems. Again the problem is that no package/dependency management for C/C++ means that C is balkanized and more difficult to deal with compared to other languages. Using third party libraries in C is far more difficult and error prone than it ought to be. Pretty much every language that provides more comprehensive dependency management also provides easy enough access to allow you to NIH/DIY it if you need/want to. For instance contrast this with something like rust where cargo is standard across all supported platforms and provides proper dependency management. You can still call the rust compiler (rustc) and whatever linker yourself if you so desire.