> The compiler will always support old code written against older editions, but the language can still introduce breaking changes in newer editions. Developers can either opt in to new editions and migrate their code, or do nothing, and things continue to work fine. There is seamless/transparent interoperability.
This is exactly what the GODEBUG scheme described in the article is intended to allow.
> We will define a new GODEBUG setting that allows individual programs to opt out of the new behavior.
The setting is opt-out, requiring manual intervention.
> GODEBUG settings added for compatibility will be maintained for a minimum of two years (four Go releases)
So there is no indefinite backwards compatibility, like with Rust.
> A program can change individual GODEBUG settings
So you need to potentially very carefully monitor your settings, and be mindful of how you deal with them. This can also theoretically lead to a pretty big complexity explosion. The mess that is Haskell langauge features comes to mind, which can be enabled or disabled per source file, and are sometimes incompatible...
This also means that you can't have differing settings for different libraries, it's application-wide configuration.
I'm sure this will be mitigated in Go by using these feature toggles very conservatively, by still avoiding those changes where possible, and by tooling that helps to migrate.
But the Rust approach still seems preferable to me. As mentioned, though, the Rust approach currently doesn't account for standard library changes, which would sometimes be possible, but hard to pull off.
No. If a module's go.mod files declares go1.21, the compiler will use go1.21 semantics when building it, even if 1.22 has already been published and the module is being used from a 1.22-enabled program. This is explicitly mentioned in the blog post.
"This crate is edition X, and an edition comes out every 3 years or so" is much easier to deal with.
It reminds me a bit of Haskell language pragrams, which can be toggled per source file (module), and which are a huge mess.
And even link different versions together?
Because it sounds like Rust uses the same approach with the benefit of not hitting all the problems this causes... yet.
We will never break compatibility is code for "we will never fix warts and mistakes in the language".
Java and C++ have invested tremendous amounts of effort into preserving backwards compatibility for decades, often requiring bending over backwards and very suboptimal designs for new features, especially in C++.
But it keeps users happy. At least the ones with large old code bases.
I think Rust has one of the best models: editions.
The compiler will always support old code written against older editions, but the language can still introduce breaking changes in newer editions. Developers can either opt in to new editions and migrate their code, or do nothing, and things continue to work fine. There is seamless/transparent interoperability.
Of course Rust is still pretty young, and if this model will work long term remains to be seen. For example, I imagine this causes a lot of implementation complexity in the compiler, the standard library is much more restricted and must remain stable across editions, and major overhauls probably won't be possible.
But so far it has worked out really well, allowing the team to fix warts and mistakes in the language.