3 ms·
> Most programming-language communities manage the code-reuse/dependency-hygiene tradeoff by concentrating code into a relatively small number of large librarie
by kbenson 11y ago
> Most programming-language communities manage the code-reuse/dependency-hygiene tradeoff by concentrating code into a relatively small number of large libraries, and when people want a function or two that isn't in one of the libraries they're using, they incorporate it by copy-paste.
I don't think it's necessarily "most programming languages". I know Perl, and probably Python and Ruby, have very large ecosystems of small modules. I suspect it's more along the lines of static vs dynamic, or compiled vs interpreted.
> On the other hand, each dependency you add creates a little bit of risk: that the package will be updated in a way that breaks your application, or the package maintainer will go rogue, or the package will get hijacked.
Those specific risks are not necessarily from including a module, but are from subscribing to a module. If you include a specific version of a module and can confirm it has not changed to a degree that satisfies you (whether that's keeping a local copy to build from, or trusting the distribution system to be immutable and pegging a specific version to install), then your risk is fairly well defined. It's not zero, but it is limited to the problems the module existed with at the point you reviewed and included it.
Subscribing to a module, that is having the system download and build "the latest and greatest of whatever thing you call $foo" is not very safe, and if the build mechanism can execute arbitrary code and is automated, is insanity.
- wereHamster 11y ago> If you include a specific version of a module That only works if the central registry is append-only. But as we've seen packages can be removed from npmjs, which caused these problems.
- kbenson 11y agoThe scope of my comment is obviously beyond just NPM, and I addressed that specific complaint, so I'm not sure how this comment follows mine.
- msbarnett 11y ago> I don't think it's necessarily "most programming languages". I know Perl, and probably Python and Ruby, have very large ecosystems of small modules. I suspect it's more along the lines of static vs dynamic, or compiled vs interpreted. The Perl, Python, and Ruby communities might have a lot of "small-ish" modules, compared to something like Boost in C++, but the Node.js community has really taken it to a new extreme with an explosion of "one-liner" modules like the absurd user-home https://github.com/sindresorhus/user-home https://github.com/sindresorhus/user-home The rallying cry of this movement is "Modules are Cheap in Node.js!". Incidents like this help demonstrate that explosive growth of your dependency graph isn't ever cheap, in any language.
- kbenson 11y agoIf that's the case, that is rather excessive. I hope there's at least a movement going on to shift towards using utility modules that combine a few tens of these one-liners into a cohesive namespace/class/object where complementary. Keeping track of many, many very small modules does indeed impose a cost, which it looks like some NPM users have gotten around by doing the absolute minimum to keep track. This is the result.
- brudgers 11y agoThere are modules that combine modules. Alas due to the beauty and power of combinatorics, there will inevitably be more compound modules than atomic ones. If there are not already.
- kbenson 11y agoYeah, I meant combine less in the "concatenate into one large new module automatically" and more "someone as put out what is rapidly becoming the de-facto standard for all OS high level actions in a comprehensive single module." I don't see automatic combination of lots of small modules actually making this situation better in any way. Quite the opposite, actually...
- thrillgore 11y agoI continue to be amazed by how far some people will take abstraction for the most menial of components.
- mshenfield 11y agoI agree that there is a definite cost of dependencies. I don't agree with the implication that these small modules are frivolous - doing one thing and doing it well is a time honored Unix principle. It saves developers from having to roll their own dependency, and gives them free wins if the package is well maintained and widely used. Edge cases are often identified and accounted for, even if the responsibility of the package is tiny. The example you gave was a poor choice - read further down https://github.com/sindresorhus/user-home#why-not-just-use-the-os-home-module https://github.com/sindresorhus/user-home#why-not-just-use-t.... It exists to avoid exactly the problem that sparked the conversation around npm today.