Rust Solved Dependency Hell
stephencoakley.com
stephencoakley.com
Compare the solutions: "It seems there's four basic components incorporated in a mangled symbol name:"
* "The fully qualified name of the symbol." -- same in Java
* "Generic type parameters." -- missing in Java because of type erasure
* "The name of the crate containing the symbol." -- represented by the class loader in Java
* "An arbitrary “disambiguator” string" -- not present in Java, and I'm not sure why this is needed at all
It even comes with almost the same downsides: "This solution isn't perfect though:"
* "...we can't pass objects around between different versions of a library" -- similar with OSGi (you can pass objects using the opaque "Object" type), but you might be able to have libraries agree on a common interface, defined by an "API library", which has the same version for both and allows to pass objects.
* "Any static variables or global state will be duplicated" -- same with OSGi * "Our binary size increases necessarily" -- same with OSGi
(edit: formatting)
Are there any circumstances in which this approach can have undesirable behavior, for example if the dependency has to deal with some global state?
This seems like the kind of thing that could create difficult-to-understand problems if Cargo gives you two copies of a dependency only under specific and rare circumstances. (But I'm happy to be proven wrong, and I'm sure the Rust folks have thought this through more carefully than I have.)
I agree that how rust does it is a very nice solution.
It uses a Cargo feature meant to be used by native libraries: you typically can link them only once (or else the build will fail when it finds repeated symbols), so Cargo must ensure only one is present on the entire dependency graph. And IIRC Rayon depends on an auxiliary crate that fakes a native lib and provides the thread pool.
If this seems very hacky and convoluted, it's because it is.
Need random numbers? Then you need this create. Is it first party or written by some random dude? Hard to tell.