Java Annotations
whyjavasucks.com
whyjavasucks.com
http://softwarecave.org/2014/05/20/repeating-annotations-in-...
And it's clear from reading the annotation documentation that null is not a valid value. It might be surprising to some developers, but it was a conscious decision made by the spec designers. It also shouldn't be a surprise to the author that Java is smart enough to forbid you to set a null value regardless of whether it was specified directly or they used a constant:
http://stackoverflow.com/questions/1178104/error-setting-a-d...
"I hate X" piece like this do nothing to advance the discussion on language features. They only add a bunch of noise and ramp up the flamewars on both sides.
[1] http://openjdk.java.net/jeps/120
[2] http://blog.functr.com/2012/09/java-8-features-discover-repe...
If there is something I can't do well with Java, then I have Groovy. I will most likely waste time trying to implement the same thing with C#. In fact I would probably just use Python or C instead.
I've used build/release management/dep management tools from/like go, python, ruby, node, erlang, make, autotools and cmake and I've never before had to read a manual to tweak an existing setup.
Go is probably my favourite ecosystem because everything is very simple. I suspect Rust will be good as well.
Fortunately not everyone in the Java community is happy with the way things are. Indeed, Java 8 fixes some of the issues mentioned here, like repeating an annotation. Obviously this wasn't some brilliant insight developed in a vacuum, people looked at C# and thought "Neat, I want that!", and now Java is a better language because of it.
As engineers we should not settle for the way things are. One day we'll hopefully have Reified Generics, maybe properties and other obviously good ideas, and no thanks to the people who are happy with Java as it is now. "People who say it cannot be done should not interrupt those who are doing it" comes to mind.
I just don't see the need for this kind of negativity. If a language wasn't designed for a certain way of using annotations (or any feature), maybe another method should be tried to get similar results. It may not be ideal and may not fit the paradigms of what you're used to, but it's a completely different language for heaven's sake.
It's like asking why a Honda Accord isn't faster than a Lamborghini... But at least the Accord holds 4 people and has useable trunk space. They're built for different needs, nobody expects an accord to race well, and nobody expects a lambo to be good for soccer moms and off-roading. So why the hate?
One of the available pluggable type systems adds physical units, something that, AFAICT, is certainly not trivial even in Haskell[2].
So the author may not like the decision not to allow null values in annotation arguments, but Java annotations have actually become a very powerful tool.
[1]: http://blog.paralleluniverse.co/2014/05/01/modern-java/#adva...
Why does the author seem surprised when his code doesn't compile after adding a non-optional parameter? It's arguable whether parameters should be optional by default or mandatory by default. Not really knowing much about c# I guess anything besides primitives will be `null`, which doesn't seem like you gain much.
I'm not sure I have ever seen annotation used like in this `whenType` example. Besides that the whole approach looks suspiciously complex (why not just create `@DefaultPriority` which you can add to your type?), annotations are supposed to be simple meta data and you shouldn't be trying to implement some kind of logic with them. Any logic like this should be done when processing the annotation in my opinion.
Java annotations sure are limited and it's does seem kind of weird that you can't use null as default value. But I never encountered any real problems that couldn't be handled by inspecting annotations using reflections or annotation processors.
Annotation in itself is not bad IMO. Used carefully as language-level extension mechanism like it is being used by Swift, it's useful.
What I disliked when annotation was first introduced is User-defined Annotation because the feature in-effect turns code into magic.
http://stackoverflow.com/questions/1624084/why-is-not-possib...
Not sure why it is a surprise to the author.
Each language has its strengths.