Why scala people don't like annotation?

后端 未结 4 1175
傲寒
傲寒 2021-02-04 01:01

Attribute in .NET is a very popular feature. And Java added Annotation after 1.5 Annotations are used everywhere, see Java EE and Spring. But few scala library use annotation. l

4条回答
  •  清歌不尽
    2021-02-04 01:30

    In general, we don't use annotations because we don't really need them for a lot of things.

    The few places I've seen annotations used:

    • Extra type systems (e.g. the CPS plugin for delimited continuations or the effect tracking plugin.
    • Interfacing with legacy Java interfaces. (scala-mojo-support)
    • Enforcing/enabling compiler optimisations, like @inline or @tailrec.

    In Scala, we don't really need a dependency injection framework, as there's a few ways to do dependency injection that doesn't require an external tool. You can have the DI config separate from core code, but still be written in Scala. See: https://github.com/jsuereth/scala-in-depth-source/blob/master/chapter11/src/main/scala/scalax/config/Test.scala

    So the basic answer is, there's nothing wrong with annotations, we just don't need them that often (yet).

提交回复
热议问题