Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Just imagine what a godawful mess it would be to write really complex libraries that are supposed to be composable in C. (I'm going to argue this is why there is no 'npm' or 'maven' for C)

The point of programming C is it is very low level and you have complete control over memory allocation so you're losing much of the benefit of C if you have a one-size-fits-all answer.

The application might, in some cases, pass the library a buffer that it already allocated and tell the library to use it. In other cases the application might give the library malloc and free functions to use. It gets complicated if the application and library are sharing complicated data structures with a network of pointers.

In simple cases you can find an answer that makes sense, but in general the application doesn't know if a library is done with some memory and the library doesn't know if the application is done with it. But the garbage collector knows!

It is the same story in Rust, you can design some scheme that satisfies the borrow checker in some particular domain but the only thing that works in general is to make everything reference counted, but at least Rust gives you that options, although the "no circular references" problem is also one of those design-limiting features, as everything has to be a tree or a DAG, not a general purpose graph.



The reason there is no npm/maven for C, is because UNIX culture prefers Makefiles and packages on whatever format the actual UNIX implementation uses.

Depots on Aix, pkgsrc on Solaris, tgz/rpm/deb on Linux, ports on BSDs,...

In any case, I would argue that we have npm/maven for C, and C++ nowadays, via CMake/Conan/vcpkg.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: