11

has 92 questions and is supposed to be used for Java's type annotations, based on the tag excerpt and wiki:

Type-Annotations are released with Java SE 8 release.

However, the majority of the questions under this tag are actually for Python's type annotations, or type hints.

My suggestions:

There are also 27 questions that don't fall under either language, but I'm not a SME for these languages, so I'm not exactly sure what the best course is.

9
  • 6
    SME here - TypeScript has type annotations (technical term). I suggest we just update the tag wiki to make the tag generic, the concept is common enough for multiple languages. Although it won't hurt to retag Python's questions to [type-hinting] while we are at it as those ain't, strictly speaking, type annotations. They are close enough, on the other hand, to just consider synonymizing.
    – 0Valt
    Commented Aug 31, 2022 at 21:41
  • 16
    Python type hinting is built on top of its annotations syntax. "type annotations" is an entirely correct term for these annotations. So it's not all that surprising the tag has been co-opted by the Python community.
    – Martijn Pieters Mod
    Commented Aug 31, 2022 at 21:45
  • 1
    I'd say that maybe we should just consider making [type-hinting] a synonym of [type-annotations], @MartijnPieters? Granted, they aren't called the same, but they are similar enough in principle (as we both mentioned), so there doesn't seem to be any harm in synonymizing.
    – 0Valt
    Commented Aug 31, 2022 at 22:09
  • 2
    Are Java's type annotations somehow fundamentally different? Are type annotations not just a form of type hinting? (I can think of two reasons to use a type annotation: because a human will read it, or because a compiler or other tool will parse it; in either case, it seems fair to me to say that a type is being "hinted" to the reader or the parser respectively.) What's wrong with tagging the Java questions about this feature as [java] [type-hinting], and the Python questions as [python] [type-hinting]? Commented Sep 1, 2022 at 4:49
  • "AFAIK these annotations are used for additional metadata, not type hints" - I would agree there. The type hinting is done through generics. Type annotations provide additional meta data about said type. I.E. "cannot be null" or "cannot exceed 100 characters". I kind of find it confusing to call them so specifically type annotations; they're just annotations in the end.
    – Gimby
    Commented Sep 1, 2022 at 11:02
  • 4
    @KarlKnechtel: No, the term is used completely differently in Java. Java has a feature called Annotations which allow you to add metadata to methods, interfaces, classes, and enums. Crucially, for a very long time, Java did not allow you to annotate types. E.g. you could not write something like class Option<@NotNull T>. That is what the type annotations feature in Java added: these are annotations for types, not annotating something with a type. Commented Sep 1, 2022 at 22:24
  • 2
    There are essentially two problems here: 1) the Java community chose an extremely confusing name for this feature by naming it something that already has a well-defined meaning and 2) this tag makes the same mistake, by using the generic term to apply only to the niche usage. Commented Sep 1, 2022 at 22:27
  • How this tag makes more easy to answer these questions in a way that the title/body can't do it?
    – Braiam
    Commented Sep 2, 2022 at 12:14
  • Note that [annotations] and [java-annotations] exist as well.
    – dan1st
    Commented Sep 5, 2022 at 6:53

2 Answers 2

1

I retagged all Python questions to , a tag I consider more specific and suitable, and I'll continue doing so for future questions as well. This is done before I'm aware of this Meta question.

There are 37 questions left in the tag:

All of these are topics I'm unfamiliar with. Perhaps the corresponding tag experts could chime in and help cleaning up the rest.

-3

Collecting the thoughts in the comments, as well as some of my own.

Java seems to have co-opted the term "type annotation" for their own feature, which is a specific use of a Java @annotation applied to a type. It is not an annotation that indicates a type, it's an annotation that indicates information about a type.

For the general-purpose, language-agnostic "ascribing a type to a term", we already have . I don't particularly see a need to have Python-specific version of this. The Java feature, on the other hand, could use a tag, but it's niche enough that it should not have the generic name .

With that in mind, here's what I'm proposing.

  • Rename to something with "Java" in the name, such as as suggested by OP.
  • Retag any Python questions that were incorrectly tagged with . With only 92 questions, this should be doable by-hand.
  • Let die a quiet death. If it becomes a problem again, consider blacklisting the name.
5
  • 2
    I think "type annotation" is the more general term because "hint" implies that it is not necessary to write it; at least in TypeScript, a type annotation is often mandatory, not merely a "hint", so we use the term "type annotation" and the official docs do, too.
    – kaya3
    Commented Sep 2, 2022 at 9:54
  • 2
    note that the term type hinting means something entirely different in java. Type hints in java refer to explicitly providing the generic types of called methods: myObj.<SomeType>someMethod(foo, bar); where <SomeType> would be the type hint. Another example can be found here. So I would not nuke [type-annotation] and replace it with [type-hinting]
    – Lino
    Commented Sep 2, 2022 at 10:37
  • 3
    Just to be sure, aren't those called type witnesses? @Lino
    – 0Valt
    Commented Sep 2, 2022 at 20:50
  • 1
    @OlegValteriswithUkraine oh, you seem to be right. Even though it is the (potentially) official term. Type hint seems also to be used thoroughly.
    – Lino
    Commented Sep 2, 2022 at 22:01
  • Thanks for confirming, @Lino - I am no Java programmer, just wanted to clarift that I understood the spec correctly, and that's how they are officially called. They do seem to function exactly as explicit type annotations / hints in other languages, agreed on that.
    – 0Valt
    Commented Sep 7, 2022 at 15:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .