Hey, folks! I developed a little-config and powerf...
# feed
s
Hey, folks! I developed a little-config and powerful dependency injection framework! https://shawxingkwok.github.io/ITWorks/docs/jvm/tracer/usage/annotations/
🙌 1
j
I think the need to implement generated interfaces will block its adoption
l
I'd love to see a comparison between Tracer, Koin, KodeIn and Dagger/Hilt. I know there is
Tracer has several main advantages over common DI tools, as listed below:
Minimal configuration. Powerful: generic types and variances are parsable, and it can trace super types as well.
But it's a bit too abstract for my mind
âž• 1
s
1. It's certainly a disadvantage for
Tracer
to implement generated interfaces. I hope one day
Tracer
is integrated into Kotlin system as the new syntax. 2. It's too long to make a true comparison. In a big project, Koin, KodeIn, Dagger/Hilt should care about lifecylcles, and maybe dependency cycles further.
j
Snippet about that new syntax?
s
message has been deleted
j
Copy code
root class House

nodes(House)
class Bedroom{
    val bed = Bed()
}

tracer(Bedroom)
class Bed{
    private val house get() = __House
}
I doubt a lot they add those keywords if they didn’t even add a new keyword for Compose
âž• 2
s
I feel Annotations as compiler instructions serve a purpose here an I'm fine with how it is with Compose
s
There is no need for Compose to do this. With my expected Tracer syntax, there hints you to build when you finish inputting
nodes class Bedroom
and makes
Bedroom
implement
BedroomTracer
automatically. Although
context receiver
is not adaptable on Kotlin-JS and Kotlin-Native at present, they are realizable theoretically.
j
Anyway, context receivers doesn't provide you that syntax?
Copy code
class House

context(House)
class Bedroom {
    val bed = Bed()

    // generated somewhere
    val __House get() = this@House
}

context(Bedroom)
class Bed {

     // generated somewhere
     private val __House get() = __House
}
Although context receiver is not adaptable on Kotlin-JS and Kotlin-Native at present, they are realizable theoretically.
That is because it isn't finished yet, the final implementation will work with all targets
With my expected Tracer syntax, there hints you to build when you finish inputting nodes(Bedroom) and makes Bedroom implement BedroomTracer automatically.
You don't need a new keyword for that anyway, an annotation is enough
s
context(Bedroom)
keeps the same. But
@Nodes class Bedroom : BedroomTracer
changes to
nodes class Bedroom
. Next Kotlin plugin hints at you to build.
j
nodes(Beedroom) Bed
would be exactly the same as
@Node context(Bedroom) class Bed
inside a compiler plugin if I am not missing anything. No need for a new keyword.
You can add any supertype you want automatically based on an annotation, in this case,
@Node
s
You can add any supertype you want automatically based on an annotation, in this case,
@Node
It's different from your expected compiler plugin. Because the interface generates after building.
j
That is not correct, with K2 you can add the supertype in frontend (FIR)
s
That is not correct, with K2 you can add the supertype in frontend (FIR)
j
And, you are able to generate the structure of those interfaces in frontend too.
s
That is not correct, with K2 you can add the supertype in frontend (FIR)
Ok, I will learn further and optimize
Tracer
. Thx!
j
Main issue is you can do that with KSP, you need a compiler plugin using K2
s
Main issue is you can do that with KSP, you need a compiler plugin using K2
Got it! I appreciate your help.
🙂 1