News from the trenches — What’s next for Koin?
This is now 3 months that Koin 1.0 has been launched, the first version tagged as production-ready. This has been also a great period for conference talks and some interviews. And no update since 1.0.2 release? 😱Don’t worry and let’s see together the next big things for Koin! 🎉
Koin, a game changer for the ecosystem✨
From this summer, it was not only a time for developing the first stable release of Koin. I got some cool interviews with Hadi Hariri for Talking Kotlin and with Benjamin Monjoie & Yannick Lemin for Android leaks. I also prepared some talks about Koin (Android Renne's meetup in France & Mobilization conference in Poland) and prepared a workshop about Android architectures & architecture components (with Koin inside of course) with Laurent BARESSE (Devoxx Belgium & DevFest Nantes) and Florina Muntenescu (DevFest Nantes).
When I started Koin in 2017, I couldn’t imagine that it could be shared and enjoyed by many people. I really appreciate that it helps developers around the world. Meeting people at conferences, talking and sharing about Koin is a great experience 👍
A good surprise was to see Koin on a slide from Andrey Breslav at KotlinConf 2018, listing the most important Kotlin open source projects!
The project has now reached 2600 ⭐️ on Github, it’s pretty cool and indicates that it still interest people 🙂
I’m not the only one who talks about Koin. I begin to see more and more meetups and talks about Koin (don’t hesitate to ping the Koin twitter account). It’s a great thing, keep going guys!
Ready for production but… 🐌
The target for Koin 1.0 was clear: make stable main API and keep it simple to use and understand. The Koin module DSL is pretty good: anybody can read it, understand it without having used Koin before. It’s great and it also helps you embrace the power of the Kotlin expressions behind that. Android, Ktor & Unit/Mock testing are very important parts of the picture, it is also straightforward to use.
But we have received feedback about bad performances on Android devices. It’s a benchmark project with a big Fibonacci configuration module (~400 definitions). It was interesting to see how Koin was scaling up for “real big” project. It has also provoked some kind of reaction: Why we need yet another dependency injection framework for Kotlin & Android.
Aside from those last news, the koin-core module was gained by some technical debt and we have already some deprecated APIs that stick us to old ideas and concepts. It was hard to try to optimize Koin whereas we were still living with old stuff. Well…
Focus on performances 🚀
Those bad performances feedback made me like an electroshock. How can Koin be so far away from simple DI solution made with just a few classes? The project started on that idea but greatly derived then ?! 😕
Let’s go and rewrite internals and keep the same API! In November, after some days (and nights) with the help of Rafa Vázquez’s benchmarks, I finally got it 🙂 !
👉 Now focused on performances!
Let’s take the coffee maker sample app which is a very simple demo app. Here are its execution results.
Coffee Maker app sample — Koin 1.0.2:
Coffee Maker app sample — Koin 2.0.0-alpha-3:
And the benchmarks from Rafa Vázquez are now updated 👍 with new results from Koin 2.0.0-alpha-3. Its Huawei P8 lite results are interesting because they were the worst Koin performances for Koin 1.0.1 benchmarks:
Now check the results for Koin 2.0.0-alpha-3:
This is clearly far better now 🚀!!!
On the way to Koin 2.0 👍
This is it! Koin 2.0 is on its way to go! The project is almost ready to be used. Next step is to deliver Koin in beta versions. We still have to refresh all the documentation and website and integrate features such as FragmentFactory for Android to be able to inject Fragments like ViewModels, or fixes for Scope API.
Why a Koin 2.0? because we decided to be not directly compatible with 1.0 to allow us to unlock performances & better extensibility of the framework. This means that you will have the same API, but with different imports. You will see it’s not a big deal. We will detail anything about migrating a Koin 1.0 project to Koin 2.0.
Koin 2.0 is the start for new feature proposals. Every new feature will be developed from this target.
Hope to be able to launch a beta version before the end of this year.
A new way of starting Koin 🍃
We now have a DSL to declare a Koin application (this replaces the old startKoin function):
Android for an Android app:
Ktor also benefits from this new DSL:
Koin application DSL allows us to extend Koin in the right place, and not just reinvent a new way to start Koin for each platform. It’s also now easier to provide new platform: we just have to extend Koin application DSL to fit the platform.
Keep simple modules
Declaring a Koin module stays the same:
Performances have a price. Inner module & module names have been dropped to simplify Koin resolution chain. We also decided to drop features that try to mimic visibility & namespaces, whereas most users are using simple modules.
Global vs Local context isolation 🔍
We now have a clear distinction between Global and Local context. The Koin Global context is the Koin application instance registered to work with KoinComponent extensions and all inject()/get() features that resolve your dependencies in a global way.
The code below starts the following configuration in a global way:
For SDK makers, you can declare a local Koin application instance which you can inject in a custom KoinComponent object. This way, your components definitions, and instances will be clearly isolated from any user that use your library and Koin.
Soonly Multiplatform 🌈
One the big feature request is making Koin a multiplatform project. We have now the materials to run it. This will be our target for Koin 2.1 👍
Helping & Supporting Koin 🧐
The main resources to develop Koin is free time. And it’s not easy to unlock free time to develop Koin features, fix bugs, maintain documentation & website, give help on Slack, Github or StackOverflow and even to prepare conference talks about Koin. All of this while having a normal Job and life.
Everyone can help with Koin. You can help people using it, contribute to the code or documentation, give talks … And you can even contribute in a financial way to help us unlock office hours to work on Koin. We do need some kind of crowdfunding stuff here.
Think how much Koin helps you day by day, and how much time you save with it. People and companies can be a sponsor of Koin and help us make it better.
Thank you all for believing in Koin. Stay tuned for Koin 2.0 beta versions. Cheers 😊