Hacker News new | ask | show | jobs
by ar9av 1176 days ago
Probably an unpopular opinion, and I realize I'm kind of ranting on a relatively unrelated subject, but I have become really dissuaded with the Node ecosystems dependence on seemingly boundless dependency trees. The fact that Window's file system can't handle moving project directories (without deleting the node_modules), and relatively simple projects using megabytes of raw text to work... anyways.

While I understand that you don't want to re-invent the wheel, it seems like the this is an important enough part of your project that your own implementation would be the only one without compromises.

5 comments

> Probably an unpopular opinion... but I have become really dissuaded with the Node ecosystems dependence on seemingly boundless dependency trees.

I wouldn't be quite so dramatic about that; HN as a collective loves complaining about NPM and dependency trees. (At the same time, it loves complaining about NIH syndrome. Although I suppose existent but limited dependency trees are far from an impossibility.)

E.g., https://news.ycombinator.com/item?id=35243196, https://news.ycombinator.com/item?id=35210975, https://news.ycombinator.com/item?id=35070210, https://news.ycombinator.com/item?id=34940437, https://news.ycombinator.com/item?id=34932957, https://news.ycombinator.com/item?id=34785080, https://news.ycombinator.com/item?id=34779769, https://news.ycombinator.com/item?id=34768828, https://news.ycombinator.com/item?id=34708290, https://news.ycombinator.com/item?id=34686056, ...

as a developer you can also keep a relatively low number of dependencies, and mainstream or simple ones
Yup for sure, 100%. Pulling in a library every time you don't know how to do something is a choice. Only pulling in dependencies that have 10,000 Github stars or are in every react Youtube video without evaluating alternatives is also a choice. I learned to be way more discriminating about npm libraries from a tech lead a few years ago, and to be honest it's one of the best lessons I've learned in a while.
But it is not a viable choice anymore to “not include this useful dependency, because its dependency tree is huge, so I will just rewrite it from scratch”, which is what practically happens in most cases. No one deliberately imports bullshit like leftpad on the root level. If you use react alone it will probably already make enough of a mess that windows’s file operations will take considerable time on your node_modules folder, which is ridiculous in and of itself.
Nobody is saying "rewrite everything".

We're saying "think about each dependency you're considering pulling in. Maybe have a quick browse through the code. Is it a gigantic hot mess? Is it tiny and elegant? Does it only have 3 downloads/week on npm? There are lots of things you can do before deciding to rewrite it yourself, but yes, I argue there are definitely some dependencies where that is the right call. But also, YMMV - it depends on your team and resources too.

there are room between huge dep tree and rewriting everything, that's where we should aim

for leftpad, even if I know it's just an example, there's a native String#padStart, and else lodash is pretty small, most mainstream libs have few deps actually

That takes awareness and discipline. The last time I tried to learn Node, all the guides led you down a road of dependency hell.
Not following a guide takes awareness and discipline too. Furthermore, if you are simply learning Node, aren’t the downsides of dependencies moot?
Tolerating an iceberg of bad habits under a surface of abstractions is a way to get up to speed on something fast, but you eventually have to invest time learning better ways to do things. Except in web development where it's normal to send multi-megabyte blobs to the browser.
If you always in include 'vanilla' as a verbatim search term when looking for Node.js tutorials you'll get better results that tend to avoid that problem.
that takes experience, like everything you want to do well
That same comment, translated to gamer speak 'just git gud, bruh!'
I don’t necessarily disagree but I have to say that in 10 years of working almost daily with sizeable node applications, this hasn’t been a problem for the past 7 or 8 years.

Maybe I shot myself in the foot enough times to have learned what not to do.

> The fact that Window's file system can't handle moving project directories (without deleting the node_modules)

Windows-based developer here. Don't use Windows node. Use the Linux x64 build in WSL.

What's that got to do with it being low to spam them?