gpt4 book ai didi

scala - Scaldi 和 Guice 和有什么不一样

转载 作者:行者123 更新时间:2023-12-04 18:29:21 27 4
gpt4 key购买 nike

我现在在一个使用 的项目中工作。斯卡尔迪 ,我正在学习它,到目前为止看起来不错,但我仍然没有弄清楚它提供的实际功能指南/果汁。

这两个框架之间的实际区别是什么?

Scaldi 更注重功能吗?

如果我从一个移动到另一个,我会失去/得到什么?

最佳答案

Guice is a java library, so its also implemented in terms of java idioms and common patterns (it heavily uses annotations and reflection). Scaldi from the other hand is implemented in terms of common patterns and idioms of Scala. So it uses implicit parameters, type classes, macros, type tags, etc. One important goal of scaldi was to avoid use of annotations, reflection and runtime bytecode manipulation. Even though very small portion of it uses scala reflection, for the most part it's reflection-free. This means that you are in charge of instantiation of your classes (it's not done via reflection). As a direct result of it, scaldi uses implicit Injector parameter, which is necessary for the implementation of annotation/reflection-free injection mechanism. Scaldi also has several features that I haven't seen in guice, like conditional bindings, property injector or macro for constructor injector (which is similar to macwire, but uses scaldi's injection mechanism).



Source

关于scala - Scaldi 和 Guice 和有什么不一样,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41354028/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com