4 ms·
Cyclical dependencies are a feature, not a bug. Many languages don't allow such a feature to exist at all with their compilation/interpreter models.
by qppo 6y ago
Cyclical dependencies are a feature, not a bug. Many languages don't allow such a feature to exist at all with their compilation/interpreter models.
- yjftsjthsd-h 6y agoWhat is a good usecase for circular dependencies?
- crooked-v 6y agoCompilers/transpilers seem like a prime example. For example, imagine Typescript vX using utility-library-a, which itself is written in Typescript and has Typescript vY as a dev dependency.
- yjftsjthsd-h 6y agoThat's fair. Does npm have a way to declare build vs runtime dependencies? That would at least let you qualify that kind of thing (although only somewhat). (Sorry if this is a noob question; I'm interested in package managers, but I've never meaningfully worked with NPM specifically, so I don't know some of the local context.) EDIT: Looks like that's devDependencies? So we can at least sometimes prune the runtime dependencies, which is nice. EDIT2: Actually reading more I'm not sure devDependencies is quite that same, although it's similar.
- diiq 6y agoYou're right, that is a perfectly valid occurrence! However, I did not count dev- or peer- dependencies in cycles; only true-blue dependencies. So all the cycles I counter were either not of that type, or failing to use devDependencies -- which would also be unfortunate.
- qppo 6y agoProblem domains where you have tricky algorithms with weird edge cases, like complicated graph searches/traversals, computational geometry, linear algebra. You'll often compose your algorithms out of other algorithms, pulled in as dependencies. Then your algorithm can be used by an upstream dependency if it resolves some weird edge case. Things like first class functions or programming with combinators naturally leads to those kinds of dependency graphs, it's basically a form of recursion.