Go += Package Versioning
I&#x27;m going to comment mostly on the parts of the proposal that I think are wrong, but don&#x27;t take this to be an overall negative response. I&#x27;m excited to see smart folks working on this, and package management is a really hard problem. There are no silver bullets to code reuse.<p>Context for those who don&#x27;t know: I along with Natalie Weizenbaum wrote pub[1], the package manager used for Dart.<p><i>&gt; Instead of concluding from Hyrum&#x27;s law that semantic versioning is impossible, I conclude that builds should be careful to use exactly the same versions of each dependency that the author did, unless forced to do otherwise. That is, builds should default to being as reproducible as possible.</i><p>Right on. Another way to state this is: Changing the version of a dependency should be an explicit user action, and not an implicit side effect of installing dependencies.<p><pre><code>    import &quot;github.com&#x2F;go-yaml&#x2F;yaml&#x2F;v2&quot;
</code></pre>
<i>&gt; Creating v2.0.0, which in semantic versioning denotes a major break, therefore creates a new package with a new import path, as required by import compatibility. Because each major version has a different import path, a given Go executable might contain one of each major version. This is expected and desirable. It keeps programs building and allows parts of a very large program to update from v1 to v2 independently.</i><p>It took me several readings to realize that you encode the major version requirement <i>both</i> in the import string and in the module requirements. The former lets you have multiple copies of the &quot;same&quot; module in your app at different major versions. The latter lets you express more precise version requirements like &quot;I need at least 2.3, not just 2.anything&quot;.<p>I think it&#x27;s really going to confuse users to have the major version in both places. What does it mean if I my code has:<p><pre><code>    import &quot;github.com&#x2F;go-yaml&#x2F;yaml&#x2F;v2&quot;
</code></pre>
But my go.mod has:<p><pre><code>    require (
      &quot;github.com&#x2F;go-yaml&#x2F;yaml&quot; v1.5.2
    )
</code></pre>
I don&#x27;t know if the goal of this is to avoid lockfiles, or to allow multiple versions of the same package to co-exist, but I think it&#x27;s going to end up a confusing solution that doesn&#x27;t cleanly solve any problem.<p>For what it&#x27;s worth, Dart does not let you have two versions of the same package in your application, even different major versions. This restriction does cause real pain, but it doesn&#x27;t appear to be insurmountable. Most of the pain seems to be in the performance issues over-constrained dependencies caused in our old version solver and not in the user&#x27;s code itself.<p>In almost all cases, I think there is a single version of a given package that would work in practice, and I think it&#x27;s confusing for users to have an application that has multiple versions of what they think of as the &quot;same&quot; package inside it. This may be less of an issue in Go because it&#x27;s structurally typed, but in Dart you could get weird errors like &quot;Expected a Foo but got a Foo&quot; because those &quot;Foo&quot;s are actually from different versions of &quot;foo&quot;. Requiring a single version avoids that.<p><i>&gt; I believe this is the wrong default, for two important reasons. First, the meaning of “newest allowed version” can change due to external events, namely new versions being published. Maybe tonight someone will introduce a new version of some dependency, and then tomorrow the same sequence of commands you ran today would produce a different result.</i><p>No, I think newest (stable version) is the right default. Every package manager in the world works this way and the odds that they <i>all</i> got this wrong are slim at this point.<p>At the point in time that the user is explicitly choosing to mess with their dependencies, picking the current state of the art right then is likely what the user wants. If I&#x27;m starting a brand new from scratch Ruby on Rails application today, in 2017, there is no reason it should default to having me use Rails 1.0 from 2005.<p><i>Every</i> version of the package is new <i>to me</i> because I&#x27;m changing my dependencies right now. Might as well give me the version that gets me as up-to-date as possible because once I start building on top of it, it gets increasingly hard to change it. Encouraging me to build my app in terms of an API that may already be quite out of date seems perverse.<p><i>&gt; This proposal takes a different approach, which I call minimal version selection. It defaults to using the oldest allowed version of every package involved in the build. This decision does not change from today to tomorrow, because no older version will be published.</i><p>I think this is confusing <i>older</i> versions and <i>lower</i>. You could, I suppose, build a package manager that forbids publishing a version number lower than any previously published version of the package and thus declare this to be true by fiat.<p>But, in practice, I don&#x27;t think most package managers do this. In particular, it&#x27;s fairly common for a package to have multiple simultaneously supported major or minor versions.<p>For example, Python supports both the 2.x and 3.x lines. 2.7 was released two years after 3.0.<p>When a security issue is found in a package, it&#x27;s common to see point releases get released for older major&#x2F;minor versions. So if foo has 1.1.0 and 1.2.0 out today and a security bug that affects both is found, the maintainers will likely release 1.1.1 and 1.2.1. This means 1.1.1 is released later than 1.2.0.<p>I think preferring minimum versions also has negative practical consequences. Package maintainers have an easier job if most of their users are on similar, recent versions of the package&#x27;s own dependencies. It&#x27;s no fun getting bug reports from users who are using your code with ancient versions of its dependencies. As a maintainer, you&#x27;re spending most of your time ensuring your code <i>still</i> works with the <i>latest</i> so have your users in a different universe makes it harder to be in sync with them.<p>Look at, for example, how much more painful Android development is compared to iOS because Android has such a longer tail of versions still in the wild that app developers need to deal with.<p>If you do minimum version selection, my hunch is that package maintainers will just constantly ship new versions of their packages that bump the minimum dependencies to forcibly drag their users forword. Or they&#x27;ll simply state that they don&#x27;t support older versions beyond some point in time even when the package&#x27;s own manifest states that it technically does.<p>There is a real fundamental tension here. Users — once they have their app working — generally want stability and reproducibility. No surprises when they aren&#x27;t opting into them. But the maintainers of the packages those users rely on want all of their users in the same bucket on the latest and greatest, not smeared out over a long list of configurations to support.<p>A good package manager will balance those competing aims to foster a healthy ecosystem, not just pick one or the other.<p>[1]: <a href="https:&#x2F;&#x2F;pub.dartlang.org&#x2F;" rel="nofollow">https:&#x2F;&#x2F;pub.dartlang.org&#x2F;</a>