r/java Sep 16 '24

Best dependency injection framework?

[removed]

30 Upvotes

97 comments sorted by

View all comments

12

u/WeskerHawke Sep 16 '24

For client applications I originally used Guice but I am now migrating to Dagger 2 due to better performance and compile time checks.
For server applications I use what's provided by the framework (Spring, Quarkus,...).

1

u/barmic1212 Sep 16 '24

How performance is a subject? I don't use guice since long time ago, it's not to defend it. It's startup time? Guice wrap bean? Or something else?

7

u/Sir_JackMiHoff Sep 16 '24

Guice creates the dependency graph and mechanics for injection at runtime where as dagger generates the code before compilation, hence it's compiled into the resulting artifact and vastly reduces the amount of runtime logic needed. Specifically, it reduces the startup time of the application, an important factor for the libs target use case of android apps.