Re:Backward Compatibility, Go 1.21, and Go 2
by vocx2tx on Monday August 14, 2023 @01:55PM
(#37124224)
> The setting is opt-out, requiring manual intervention.
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.
Re:Backward Compatibility, Go 1.21, and Go 2
by tick_tock_tick on Monday August 14, 2023 @03:27PM
(#37125660)
It's basically a much more featured, flexible, extendable, and usable version of editions. Anything you could do with editions you could do with this; you could implemented "editions" via this functionality.
Re:Backward Compatibility, Go 1.21, and Go 2
by the_duke on Monday August 14, 2023 @04:26PM
(#37126362)
Yes, but that's sort of my point regarding complexity.
"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.
> 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.