Library or language extension for providing Java properties?

I just got to know traits ("traits" in Smalltalk, "roles" in Perl). I would like to experiment with them quickly, in the language I am familiar with. Are there libraries or extensions in Java that support traits?

I heard that AspectJ and Qi4J support mixins, but I also read that mixins are different from features. Can I also use one of these libraries for tags?

Or what about Scala, which is fully compatible with Java, right? Does it support features?

Any other suggestions?

+4
source share
2 answers

Or what about Scala, which is fully compatible with Java, right? Does it support features?

Yes, Scala has full support for features . He has to jump through some strange hoops to make him work with the JVM, but he is there and he is very powerful.

You can write your experiment in Scala and it will interact with your existing Java material (depending on the tools)

+4
source

Qi4j 2.0 (in its work) adds strong support for Scala, and we are working to make Scala features useful as Qi4j mixins and problems (AOP equivalents "around advice"). The Scala tag compiles to static methods, which takes an instance of the proxy of the owner class as the first argument (the classic C ++ representation in C). Qi4j will be able to connect this attribute as a Mixin (i.e. Methods can be set in the Composite open interface) and bind in the base StateHolder for the composite element that Trait will use, so it seems that the traits will have a state ...

FTR Qi4j 2.0 also minimizes font size, allowing the use of Qi4j agnostic types even more than before.

+2
source

Source: https://habr.com/ru/post/1342725/


All Articles