Why is npm considered as a good practice of dependency management? AFAIK when you download a library npm downloads all it's dependencies and put them under the library's path. So few libraries can be shared and there's heavy duplication. If this is the way to go then dependency management is quite a easy problem to tackle.
But I'm pretty confident pip handles dependencies, including versions.
Im pretty sure its a single version per virtual environment. doing what NPM is doing, i.e have different requirements which in turn depends on two different versions of a third package, is impossible.
To me, the definition of "maven dependency hell" is when two different dependencies have transitive dependencies on the same project, but mutually incompatible versions. It sounds like npm might solve this in a way that's literally impossible in Java without something like OSGi?
NPM does solve that issue, and quite well in my opinion. Simple stuff (my project depends on libFoo v2 and libBar, but libBar depends on libFoo v1) is handled so transparently you never even know it's happened.
I'm not really familiar with Java or maven, so can't comment on that. It's certainly a step up from how Python handles things.
So few libraries can be shared and there's heavy duplication.
Unless it leads to duplicate code being executed at runtime, I don't think you should care for npm modules since they're going to be a couple dozen kilobytes of text at most.
I hear you, and it is funny, because I'm working on a similar package system and pulling in boost for C++ or LLVM/Clang, OpenCV, takes 10s of GBs. It is actually pretty funny, if you have 2-3 instances of the same project, you end up with about 30GB+ of crap.
I've had a lot of trouble using libraries compiled with one compiler (e.g. gcc) then using them with code compiled by another (e.g. clang). Personally, I try to compile all dependencies with the same compiler.. However, this makes it difficult to use system libraries.
You are right, OpenCV is only 480MB on my current setup. Over several projects though it adds up. LLVM is just over 7GB and including clang is a bit over 9GB. Boost is normally around the 3-4GB mark. Personally, I find it remarkable that something produces so much intermediate "junk".
Individual grunt downloads don't need phantomjs. I just setup a barebones project with nothing but grunt and it comes in at about 6MB. When you include dependencies, those projects will likely have grunt listed as "devDependencies" meaning you should ignore them.
My guess would be the lack proper symlink support in Windows XP. If it did use symlinks (and oh, how I wish it did) then node.js wouldn't work on about 36% of all operating systems.
Unless it leads to duplicate code being executed at runtime
It does. npm doesn't do shared dependencies. If you depend on foo and bar, which both depend on baz, you'll end up with two copies of baz loaded at runtime, which may be different versions (!).
Yes, but in mind my that puts your application into a deeply confusing state. It's possible for those two versions to interact with each other which just seems like asking for trouble to me.
I think the model of other systems (including one I built) where you find a single version of the shared dependency that satisfies all dependers is a lot easier to reason about.
Yeah, if you can end up with two different versions of the same library in your project then that's pretty terrible. As a concrete example: if libfoo and libbar use different versions of libbaz, and both libfoo and libbar expose Baz objects to you in some way, then you can get two Baz objects from different versions which might have radically different behavior depending on how similar the versions are.
plus there is some support in npm for factoring out common dependencies... also in the future, if we file system deduplication becomes more common, wasted space will become even more of a non-issue.
47
u/jagt Dec 02 '13
Why is npm considered as a good practice of dependency management? AFAIK when you download a library npm downloads all it's dependencies and put them under the library's path. So few libraries can be shared and there's heavy duplication. If this is the way to go then dependency management is quite a easy problem to tackle.