It's primary use is to ship to a browser. However shipping an entire string-util library because you need a string prefix function is wasteful and bad engineering. But javascript doesn't have dead code elimination anywhere in it's toolchain unless you use Closure. And that really only works well if all of your dependencies are using Closure as well.
As a result of all this javascript needs a poor mans dead code elimination at the package manager level. Including a package only includes the code you will actually use. This helps to keep your javascript code that you send to the browser small. What works for Java or C++ won't work here for the above reasons.
This isn't npm's fault, it's intrinsic to javascript the language and it's primary target platform the browser.
Indeed. Moreover, it's a sign of a weak or incomplete standard library.
Early Java had this problem as well. However, since distribution consisted of passing around JAR files, most utility code was bundled in larger libraries (e.g., see commons-.*).
If by "this way" you mean microdependencies in JavaScript, you should also look at Ruby, which goes in a similar direction. And at Python, which apparently tries to follow the lead.
Which is why some decisions, like the whole npm modules, or the ruby gems before bundles (if I get it right), get to be taken without consideration how it works in large scale.
Of course people with CS background also use dynamic languages. I have Python, Smalltalk, Lisp, Perl, JavaScript on my CV.
A CS degree doesn't mean you'll be a good programmer in industry.
I have a technical school specialization in computing and a CS degree.
Many of the things we learned at technical school only made sense afterwards when I got into CS.
Also some of the design problems we had, which were solved by the usual"try something until it works", became basic programming exercises with the right CS information.
Yeah, it isn't a magic solution, but it helps in what concerns designing software in the large.
Most other backgrounds aren't exposed to such issues.
The way to reuse N lines of code is to refactor them in a function. The way to reuse functions is to pack them into libraries. This is something that probably everyone agrees with.
Many have issues with the idea that one should create libraries containing one function only! You've touched yourself upon the why: having hundreds of dependencies adds both technical and cognitive overhead. It's very hard to design things to be extended, so in practice one ends up with a fragile module, not one that can be improved by improving a dependency (I wonder how a function that checks if a number is negative can be improved...).
As far as I know there is no other toolchain on this planet where it's done this way, which together with the clarification above should be telling you and sindresorhus something!