5 ms·
The main difference is Spark is just Java. No need for reflective annotation scanning or any other magic.
by benjiweber 12y ago
The main difference is Spark is just Java. No need for reflective annotation scanning or any other magic.
- brazzy 12y agoAnnotations are just Java. Welcome to 2004!
- Argorak 12y agoI think I know what you mean, but annotations and scanning for them is definitely Java and used very widely. Honestly, when JUnit was still "just Java" by that definition, it was a much worse framework.
- guelo 12y agoThis is tangential, but before annotations JUnit still used reflection and scanning looking for methods named testXXX(). And honestly, it wasn't that much worse.
- timclark 12y agoIf I compare the lines of code between JUnit without annotations and JUnit with annotations I usually have less lines of code without annotations and I don't find it bothersome to name my test method correctly. Annotations in Java have always bothered me! Why are they needed? I don't need them in Clojure, Go, Haskell, C - similar behaviour is supplied by alternative means.
- thescrewdriver 12y agoIn many cases annotations are just a crutch to work around glaring limitations in the Java language.
- Terr_ 12y agoWhile it may use "magic" under the hood, I think the important thing is that the magical results are predictable. Annotations have their own usage-contracts, and have a certain degree of self-documenting code to tie everything together. ...So any sufficiently advanced magic is indistinguishable from science :)
- timclark 12y agoJAX-RS annotations aren't really composable - functions usually are, although I haven't looked at the Spark implementation to find out. With plain functions if I need to wrap requests or responses I just wrap the functions. With JAX-RS I need to find or write an appropriate annotation or start adding filters. With plain functions I can share behaviour between resources by sharing functions.
- meddlepal 12y agoI've been pondering the performance implications of JAX-RS recently. All that reflection cannot be good for raw performance. I love how simple it is, but my company is at the point where squeezing every ounce out of our API servers is necessary. I've been fiddling around with Vert.x a little; but another option is just to use raw Servlets.
- norswap 12y agoIt could use annotation processing (aka compiler plugins) instead. Not sure how easy that is to bundle and deploy however (it's not hard to do by hand, by don't know if you can include that kind of stuff in a maven dependency for instance).
- meddlepal 12y agoAre you suggesting something like Lombok for RESTful services? I am not familiar with using annotations at compile time to produce code; so while I guess it is totally possible, I feel like I would be doing it all from scratch.
- norswap 12y agoAFAIK Lombok plugs into Eclipse APIs, it doesn't use annotation processing. Read this to get some idea of what can be achieved with annotation processing: http://scg.unibe.ch/archive/projects/Erni08b.pdf http://scg.unibe.ch/archive/projects/Erni08b.pdf They do use so compiler API which are not stable interfaces, but even without that, you can go surprisingly far.