Why aren't annotation-based libraries so popular in Scala?

When I write Java code, I found annotation based libraries very popular, eg. hibernate

, Jackson

, Gson

, Spring-MVC

. But in Scala, most of the popular libraries do not provide annotations or do not, but recommend non-annotation approaches such as. squerly

, slick

, argonaut

, unfiltered

, Etc.

I've sometimes found annotations to be easier to read and maintain, but why aren't people so interested in them?

+3


source to share


2 answers


One reason is that annotations often need to be used on an ad site. Therefore, you must pollute your domain models with code that doesn't match your business logic. Solutions based on macros or class types, on the other hand, are usually applied in a participating site. This allows you to increase the reusability of your domain models.



For example, what if you need different serialization logic for different tasks? With annotations, you usually have no choice but to implement an additional view of your model with modified annotations. With class types (perhaps automatically derived via macros), you should just implement another instance and inject it according to your needs.

+4


source


Macros and implications can often be used as replacements for annotations and are beneficial for statics checking.



+2


source







All Articles