Comparing DI frameworks & internals
summary
Deep dive comparing Dagger 2 vs Toothpick: Dagger uses annotation processing to generate a static compile-time graph with compile-time scope verification, which makes large graphs faster and errors caught at build time; Toothpick (released 2016, built in ~2 months) also avoids reflection but generates a dynamic runtime-backed graph, creates scopes fast (~1 ms vs ~20 ms for Dagger), and makes testing simple with a rule that swaps mocks. Reflection is the core problem (constructor creation ~100× slower); Toothpick wins for small-to-medium apps, Dagger for very large injection counts (≈1,000+).
AI-written summary · about
chapters (12)
- 0:00Introduction
- 3:34Dependency injection overview
- 10:14History of DI libraries
- 16:38Reflection in Android
- 25:07Dagger vs Toothpick setup
- 30:02Scopes in DI frameworks
- 35:24Testing with DI frameworks
- 38:11Performance comparison
- 40:20How annotation processing works
- 45:40Code generation internals
- 51:01Alternatives to reflection
- 52:25Summary and conclusion
related talks
38mDagger 2, 2 Years Later
29mDagger Reflect - The circle from runtime to compile time and back to runtime
56mDI Frameworks – some hidden pearls
53mToothpick: a fresh approach to Dependency Injection on Android
30mPowering up Dagger for Less Code and Cleaner Architecture
17mKoin vs Dagger (Service Locator vs D.I.)
48mDemystifying Dagger
45mDagger 2 - Back to Basics
