5 ms·
> eg: Java annotations can change the behavior of a method from a simple getter to something else entirely with hooks to be used/referenced at runtime. To be s
by Twisol 6y ago
> eg: Java annotations can change the behavior of a method from a simple getter to something else entirely with hooks to be used/referenced at runtime.
To be slightly fair to Java, annotations don't themselves do anything to the annotated method. Calling a method directly is the same regardless of whatever annotations are on it -- of course, unless it or one of its upstreams looks at the annotations, but that's isomorphic to just passing the data along.
Java annotations induce different behaviors in specific callers that are designed to take advantage of those annotations, which is arguably even worse -- like a meta analogue of the COMEFROM keyword.
- imoverclocked 6y agoTotally agree. The annotations basically just mark code. Things like AspectJ can then place side-effects around marked (and unmarked!) code. Also, coming across transient runtime errors because you use multi-catch (a basic Java language feature) and some java library that injects bytecode is pretty lame. All the benefits of a typed+compiled language with all the benefits of monkey patching!
- ajuc 6y agoAs an aside I don't understand why COMEFROM has that bad reputation. It's just another name for aspects.
- Twisol 6y agoC# delegates are a kind of COMEFROM, from a certain perspective, so it's not a universally bad idea. The problem is just that using it in conjunction with other kinds of control flow -- like the @Annotations + method calls approach we see in Java -- tends to obscure the control flow overall and make it a lot harder to follow the high-level behavior of your system.