8 ms·
I wanna begin my journey with learnin C (again). Why isn't there a normal package management system? I mean there was a lot of time to solve this issue, is it a
by joelbluminator 5y ago
I wanna begin my journey with learnin C (again). Why isn't there a normal package management system? I mean there was a lot of time to solve this issue, is it a technical issue or just lack of innovation in C?
- numlock86 5y agoFor C there isn't really a problem that a package manager would solve. I can think of some problems it would cause, though.
- rk06 5y agoCitation needed. I am confident that it is possible to write reusable C code, and thus there is a need for packaging such reusable code and manage them
- karatinversion 5y agoLike the user you’re replying to, I to find the concept of a C package manager baffling. I don’t know what your background is, but some reasons for my reaction: - a plethora of details that are implementation specific; - different compilers and platforms that differ in important details; - as a consequence of above, most code ends up targeting some limited set is compilers and platforms; - no standard build system to build package management on top of - the header file system, which allows api declaration and implementation to be decoupled By the time you’ve narrowed down enough to make these tractable, you might as well use a given operating system’s package management tools as your “C package manager”.
- maleldil 5y agoC++ has all of these problems, but Conan and vcpkg still exist. They aren't perfect, but they're so much better than nothing. You're also ignoring the fact that Linux isn't the only operating system in the world. Some of us write multi-platform software, and package managers make it so much easier.
- thinkharderdev 5y agoI recently started working in C++ again and my experience with C++ package managers were pretty dismal (I tried vcpkg and Conan). Just trying to setup a PoC project with only two dependencies took me multiple days and neither Conan nor vcpkg worked. And this was on an Intel MBP so not exactly some exotic platform.
- maleldil 5y agoI agree wholeheartedly with you on that. It's certainly a hard problem right now, which is why I don't like people that just say "it's not a problem with C/C++" or "just use the system's package manager".
- rk06 5y agoI once worked on a C program. It has been the worst experience of my programming career, right next to updating excel's vb macro to meet newer business needs. The mere fact that I could not build the project on my local machine (windows) and have to login to a Unix (IBM AIX) was baffling. Yep, Unix, not even linux. And because it was a business critical program which worked, business refused to make any drastic changes to it unless they were absolutely necessary, even if it was a bug fix to a frequently occurring issue. And I maintained it till 2018 when I left that job. I am pretty sure it is still there in same state. So, I understand the build tool woes, and cross platform issues. however, I understand it to mean that package manager is not feasible in current environment, not that it does not add value. Recently there was a post on zig, which aims for providing a standard build tool for C (& zig), and later, a package manager for C (and zig) So, I think such efforts are not only beneficial, but will become reality in future
- phlakaton 5y agoAnd C has a solution for that: Package: tarball of code. Manage: download tarball of code and build/install libraries using configure/make. Then tell the compiler where the headers are and the linker where the libraries are. Easy peasy! (OK, we know it’s not quite _that_ easy in many cases.) The elephant in the room is that people on HN and elsewhere violently nod about the need for a “proper package manager” when they are actually in disagreement about what a “proper package manager” needs to do. Meanwhile, it turns out that you can do without one, as the C community and all the “non-proper package managers” out there amply demonstrate.
- pjc50 5y agoThe nearest thing to a standard solution may be autoconf, which is horrendous. C targets an incredibly broad spectrum of hardware and software platforms, compiler implementations, and OS layouts. That's both blessing and a curse. I think it would be worth at least trying to converge on a "package" system, even if it takes the next 20 years.
- bscphil 5y ago> The nearest thing to a standard solution may be autoconf I believe that is changing. A quite large number of influential projects have standardized on Meson. That includes systemd, Xorg, PipeWire, GLib, libui, hexchat, pacman, and (almost) all Gnome projects. It seems fair to say that most people (a) like it, and (b) see it as the most likely path forward for build systems.
- joelbluminator 5y agoAre you saying the standard library is powerful enough for most things?
- numlock86 5y agoAre you saying you need a package manager to use something other than the standard library?
- veltas 5y ago> I wanna begin my journey with learnin C (again). Why isn't there a normal package management system? That sounds like a distro.
- deleted 5y ago[deleted]
- joelbluminator 5y agoCould u explain further?
- qsort 5y agoAs absurd as it sounds, perhaps the simplest way to manage the dependencies of your C projects is to install the library package offered by your distribution. C has a terrible dependency management story.
- joelbluminator 5y agoWhy is it like that though? Do C programmers generally have less of a need for 3rd party libraries?
- qsort 5y agoThe C programming language predates the time when using third party libraries was common. When it became commonplace to depend on third party or system libraries, because of the special status C enjoys in the software infrastructure, OS and distro developers bend over backwards to accomodate C linkage, providing pre-packaged dynamic linking objects. The status quo is actually rather unfortunate. Several package management tools exist to attempt to address the issue, but there is no de-facto standard and every project makes its own choice.
- dotancohen 5y ago> The C programming language predates the time when using third party libraries was common. The English language predates spaceflight, but has adapted. PHP predates proper security practices, but has adapted. Javascript predates the Document Object Model but has adapted. For that matter, Javascript also predates the time when using third party libraries was common.
- otabdeveloper4 5y agoThere is, Nix :)
- geokon 5y agoHow does this work in practice with it's "rolling release" nature? Can you designate specific package versions for all your dependencies? Like having a very new openssl and an older zlib version? With complex software, just grabbing the latest version of every dependency will lead to broken builds (or ones that only work on x64 but are broken on other platforms) Last I looked at GUIX (which I guess is similar) you are tied to a release "version" of the package-manager with whatever package version it comes with. But maybe I misunderstood
- rnhmjoj 5y ago> How does this work in practice with it's "rolling release" nature? Can you designate specific package versions for all your dependencies? Like having a very new openssl and an older zlib version? NixOS (the distribution) is not actually rolling: it has stable channels that are released twice a year, and an "unstable" channel that normally updates every few days (depends when all tests passed). You could call the latter "rolling", but it's a bit different compared to actually rolling distributions like Arch Linux. > Can you designate specific package versions for all your dependencies? Like having a very new openssl and an older zlib version? Normally only the last version is packaged, but you can change the version of the package and install multiple versions of the same library without conflicts. Some big libraries have multiple branches for backward compatibility (eg. boost175, boost174, openssl_1_1), for the others you have to override the package (it's pretty easy, but you'll likely lose the binary cache). > With complex software, just grabbing the latest version of every dependency will lead to broken builds (or ones that only work on x64 but are broken on other platforms) If you really need that kind of stability, a common solution is to pin the version of the whole Nixpkgs. Something a little less drastic is simply using the stable channel, which only receives security updates. > Last I looked at GUIX (which I guess is similar) you are tied to a release "version" of the package-manager with whatever package version it comes with. But maybe I misunderstood I'm not familiar with Guix, but I think you can do what I described above with it too.
- baybal2 5y agoThe closest thing to a module metadata system is the pkgconf, but it does nothing about actual module import/building. You have to use external tools to achieve the later.
- Decabytes 5y agoI feel the same way. I’m trying to learn C but there are a lot of things about it that just make it more difficult than it needs to be to learn. Like why is * used in so many different ways!? Why is it that I need to learn multiple different programs to build and install my programs (nmake, cmake, make, shell script or even .bat). Why don’t I just have a compiler already installed on Windows? And then there is specifying linking files and include files, and headers, it makes it so challenging to even run other people’s code
- pjmlp 5y agoFor the same reason you don't have a compiler already installed on commercial UNIXes, it is extra revenue for the platform owner and regular users don't need it.
- deleted 5y ago[deleted]
- geokon 5y agoin C++ (and by extension C) you can create very robust crosscompileable projects with complex dependencies trees using CMake + Hunter + toolchain files. There is a bit of learning curve but everything is there for a reason. - Toolchain files define your target system and build toolchain. - Hunter specifies your dependencies withing CMake (using git and hashes) and does proper incapsulation/namespacing (which isn't present in "normal" CMake) as well as setting up the proper "inheritance" of headers and stuff. - CMake does the final linking of build artifacts and headers and does the final build command generation. A proper setup can build both dynamic and static builds for any system with virtually no platform specific switches
- pjc50 5y agoLack of innovation (which has tended to focus on other, less limited, languages), different culture (pre-web greybeards, embedded software), fragmentation (there's a lot more C compilers in use than almost any other language, many of which have one implementation). Plus many of the implementations are closed source. C also tries to make as few assumptions about the platform as possible. It was only recently that support for ones-complement arithmetic was dropped http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2218.htm http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2218.htm / despite never being used for decades https://stackoverflow.com/questions/12276957/are-there-any-non-twos-complement-implementations-of-c https://stackoverflow.com/questions/12276957/are-there-any-n... C is also somewhat unique in supporting cross-targeting, where you build a program on platform A that will run on platform B (such as a microcontroller), and the target platform may be very different (such as no filesystem, no OS, different instruction set). Most other modern languages use intermediate bytecodes and try to be "WORA" (write once run anywhere).
- drno123 5y agoFor C++ package/lib management we use Conan+Cmake. I understand that Conan works also for plain C projects.
- wibagusto 5y agoNot sure why folks think a “nodejs” type package manager is required… For instance, what is this if not package management? apt install libpng-dev
- snerbles 5y agoIt's distro-specific, for one.
- ori_b 5y agoAt least it's not language specific.
- nicoburns 5y agoIt's pretty much C-specific. Packages for other languages tend to be pretty difficult to work with when installed this way (e.g. you end up with problems if you have 2 projects depending on different versions of the library)
- ori_b 5y agoHow so? It's normal for incompatible versions to get parallel installations.
- stingraycharles 5y agoSure that’s a package manager, but it’s a distro specific one. Now make one that works on all Linux distributions. And now make one that works on all operating systems. This is the problem that npm, pip, and whatnot solve. They work the same, (almost) everywhere. C/C++ don’t have a proper answer for it.
- yissp 5y agoYou can install apt / dpkg (or dnf / rpm, pacman, portage, nix, ...) on pretty much any distro. You are really just asking why there's no de-facto standard package manager for C like there is for those other languages.
- matheusmoreira 5y agoI assume it's because C compiler output is deeply intertwined with the host operating system as a whole.
- exdsq 5y agoCould be worth looking at CMAKE; you can even link to github repos like Go offers.