After spending a great deal of time writing C# and looking at Java, it seems to me that annotations are just an ugly code smell that introduce another conceptual layer that could easily be replaced by existing language features, whether they be keywords (as in the case of C#'s
override keyword versus Java's
@override annotation) or inheritance (why not just have a ISerializable interface or base class instead of a
[Serializable] attribute?) However, this conclusion could just as easily be due my relative inexperience as a professional programmer.
My question is compound:
- What do annotations bring to the table that cannot be accomplished in other ways, without complicating the grammar of a language?
- Are there things that can be implemented without annotations, but which would be much more difficult to implement without them?
- More generally, where (if anywhere) is the demarcation line between data and metadata in a programming language?
My question is different from What problems are Java annotations well suited to?. For starters, this question is not Java-specific. I'm wanting to know, in general, whether annotations are indispensable or merely useful. I am also curious as to the theoretical distinction between data and metadata, and how useful that distinction really is.