Hacker News new | ask | show | jobs
by 60secz 1450 days ago
> Submodules are usually good for frameworks and libraries that are more stable than your main codebase. However, those submodules under active development within the same organizations can be a pain to maintain.

Except they aren't. Libraries are better in their own code base and published as a separate artifact which is auto-versioned.

2 comments

From the article you linked:

> I know some programming ecosystems, such as C++ does not have a default way of handling libraries and dependencies, and in that case it might be good to look into submodules.

> Please, if there is any dependency management in your chosen platform use it.

I use C++. There is no such thing as package management in C++ (at least no unified standard that you can use with confidence with every library). So giving a blanket statement and saying that you should just ship library artifacts is a non starter in a language like C++. This basically implies either creating a package manager, or distributing binaries manually, or forcing users to find the correct versions manually and install them.

Git submodules is extremely helpful here, and if you look at the documentation this is what it sounds like it was created for:

> Large projects are often composed of smaller, self-contained modules. For example, an embedded Linux distribution’s source tree would include every piece of software in the distribution with some local modifications; a movie player might need to build against a specific, known-working version of a decompression library; several independent programs might all share the same build scripts.[0]

If this suggestion here doesn't sound like your use case, then your probably using the wrong tool.

In the same way, you wouldn't tell people who use a hammer to cut a piece of wood in half that the hammer must be a terrible tool. You would say something like, you're using the wrong tool, here's a saw. Use the correct tool for the job at hand. If you need source code from a 3rd party library that you won't modify but you depend on, a submodule is a fine tool for the job.

[0]: https://git-scm.com/docs/user-manual#submodules