Yes, they return Unit, but the Compose annotation ...
# compose
s
Yes, they return Unit, but the Compose annotation is hooked up to a compiler plugin and this causes some magic in generating a model/hierarchy of the views (that is what I understood from my unit-testing question here: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1557666472013700?thread_ts=1557666472.013700&cid=CJLTWPH7S )
m
soooooo crappy creepy
m
"Any sufficiently advanced technology is indistinguishable from magic"
m
Any codegen and reflection is indistinguishable from legacy-code.
1
1
m
I believe that codegen and more intelligent compilers can actually make programming less repetitive. Reflection is mostly bad as it breaks compile time type safety.
m
Programming can be less repetitive without reflection/codegen. But this requires more intelligent programmers...
m
It's just a matter of what tools programmers learn. If you learn
@JsonClass(generateAdapter = true)
, you will never need to know how to write a custom json serializer. Maybe it's a bad thing, maybe not. But then who knows how to write assembly these days...
s
But I thank all gods in heaven for abstractions and i’m willing to call a plumber or deal with the occasional leaks myself on occasion …. 🙂 I can’t imagine drawing all pixels myself, making sure that ordering UDP packages are in order and reliable (most of the time), dealing with garbage collection, etc. I think a lot of abstractions are good trade-offs (and some are not)
3
n
Is the use of annotations in Compose a good trade off considering there is a lot of magic involved with them (also increases build time)? Were other methods explored which don't require the use of annotations/meta-programming?
m
Of course it is a bad trade-off. Of course there are other methods.
r
The annotation is just a signal to the compiler. Compose isn't an annotation processor, so you won't have the drawbacks you're used to with annotation processors.
m
@Ryan Mentley I'm curious why it doesn't use a keyword (like
suspend
for coroutines) by the way. That would hint at compiler support more. Or maybe plugins cannot add keywords ?
r
@mbonnin You're exactly correct - plugins cannot add keywords. There's some discussion toward the end of this thread between Leland and Roman: https://kotlinlang.slack.com/archives/CJLTWPH7S/p1558440714121300
👍 1