New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: x/vgo: add // Unstable convention #25524
Comments
Why does this need any sort of convention or tooling-support? i.e. why not just state in the godoc comment, that an API is unstable? |
For the same reason that
To enable tooling, and to standardize on a single place where a user would discover instability notices. At the moment it varies library-to-library; some at the top of a package, some in the comments, some in the comments with different verbiage, some in a README, and so on. |
I'm sorry, I was being imprecise: Under what circumstances would you want to show these warnings? i.e. what are the use cases for tooling taking advantage of this annotation? I don't want build-warnings whenever I build a project. |
Agreed - I also don't want build warnings. This proposal does not suggest that; merely a convention for marking instability. This probably amounts to a blog post and some note in golang.org. The downstream change is twofold:
These are not warnings. I loosely used the phrase "to give users warning" earlier, apologies for any confusion. I meant that in a loose sense, not in the literal "I'm proposing a build warning feature" sense. |
I consider "unstable" and "deprecated" fundamentally different things. Using something unstable is a valid choice and once made, there isn't really anything distinguishing that code from other code. Using something deprecated should never happen voluntarily and it's warranted to be more alarming about changing it. i.e. "Deprecated" is absolutely always actionable, whereas "Unstable" seems to me to ~never be actionable. Except for the initial discussion of "should we use this", which seems just as well served by an unstructured mention in godoc to me (because before using an API, you will likely read its docs). Not all properties of Go code have to be machine-discoverable. On the contrary, we probably want to limit the amount of machine-readable special-format comments to prevent it from becoming a meta-language. IMO "Unstable" doesn't pass the bar on usefulness. That being said, I only have mild opinions about this, so I probably have said what I came to say and stay out of the rest of this issue :) |
Unstable APIs are volatile: any caller of an unstable API can break — even fail to compile! — at any future release of that API, and compilation failures affect the whole package. If you want to be strict about semantic versioning, it's ok to export an unstable API from a stable package, but it's not ok to use an unstable API in a stable package — even if it is only used in other unstable APIs. (For that reason, Google's Guava project strongly recommends that libraries do not use “beta” APIs.) So a warning is actually pretty useful, if all of these conditions hold:
That said, I don't see a way to detect the latter condition during development, because version tags are usually applied after the fact. Perhaps that implies that the warning should be in some version-tagging tool rather than the IDE? (As far as I understand, |
If a warning is actually pretty useful, the compiler should emit it, shouldn't it? Oh wait. |
It's also worth noting that
|
I completely agree with earlier posts about build warnings being an overkill. I'm not even sure if using unstable API should even be a vet warning. I think it makes sense to warn when using deprecated APIs; presumably you can use something else to silence the warning. When using unstable API, there might not be anything for you to move to. I think there's value in godoc.org displaying "Deprecated" and "Unstable" in bold though. It should catch attention without hurting the eyes too badly. Even if that's all we get from the convention, I think it's a net win overall. @bcmills Just as we have
I'm slightly concerned that this might encourage people to make unstable APIs and not stabilize them. Does anyone else feel the same way? |
I do, although I figure this is something that will happen whether there is an |
nit: I wouldn't include changing return types in this list due to type-inference. A classical example would be, to change an
this change would break, because the types of |
I was wondering if anybody would call me on that one. 🙂 It turns out that “call-only” is actually (at least) two points on the spectrum. One is “call-only, but inferred types are stable”, and the other is “call-only, and don't make assumptions about inferred types”. |
In Go, I question the wisdom of I'm not sure there's much proposal to evaluate here and am inclined to just close this. |
That's reasonable. I agree that stronger enforcement would be better - like some explicit opt in - but it's unclear to me what form that should be in. I'll close this issue in the meantime. |
Note: This proposal is only pertinent in a vgo-world.
Proposal
Support a convention for describing structs, methods, functions, and interfaces as unstable with
// Unstable
. This convention might later extend to IDE support, Godoc formatting, and so on.Rationale
Backwards compatibility is important for the Go ecosystem, but absolute backwards compatibility is a heavy burden for maintainers of libraries. Consider the case where a library author wishes to extend their library with a new function, but is unsure what the exact function signature will look like (alternatively, the behavior):
// Unstable
. Each time they iterate on the API of this function they bump the minor version, breaking users (since it's marked unstable, users expect breakages).The first two paths are very onerous; creating new packages and unnaturally segregating code is not a great experience, and bumping major versions for small things is not a great experience either. On the other hand, the "Bad" path of choosing to break users is not a good experience for users of libraries. This proposal gives library maintainers some room in the middle.
The text was updated successfully, but these errors were encountered: