https://kotlinlang.org logo
#compose
Title
# compose
g

gabrielfv

03/26/2020, 6:46 PM
This might have been answered before, but given the current need for a successful build in order to have a working preview, does it worry you guys that Compose may become unsustainable in larger apps that have a build time greater than one minute? Is anything in the works so that something like a "real-time pre-build" sort of thing allows for a reasonable fidelity preview or something else?
l

Leland Richardson [G]

03/26/2020, 6:51 PM
yes, for sure build times are top of mind for lots of folks over here and there are a number of things that are being worked on in this vain. I don’t think there are any silver bullets here, but there are a few things in the works that will be helpful
👍 1
z

Zach Klippenstein (he/him) [MOD]

03/26/2020, 7:18 PM
You only need to build the current module to get the preview though, right? So after the first build, once all the dependencies have been built and cached, as long as your module compiles relatively quickly this shouldn’t be too bad, I would hope.
l

Leland Richardson [G]

03/26/2020, 7:20 PM
yes, but we can do better
z

Zach Klippenstein (he/him) [MOD]

03/26/2020, 7:25 PM
SwiftUI-like instant rendering would be amazing 😅
l

Leland Richardson [G]

03/26/2020, 7:26 PM
it’s important to note that that only works with constant literals, but yes, we are planning on doing something similar in these cases
g

gabrielfv

03/26/2020, 8:48 PM
Well, potentially build more than one module if you're composing components scattered around modules. IIRC, building a module will trigger a rebuild of other modules that depend on it (which is plausible for an ui-components sort of module). The mileage may vary, but in my experience modularization can still have relatively long rebuild times, enough to make something like building a UI, that requires a decent amount of tinkering, quite a tedious effort
Compose is a huge step forward in terms of creating views in android imho, but this build thing might make it a hard sell. I'm sure the engineers will eventually come up with something to deal with it, I just asked to have some insight. I'm just beginning my deep dive into compose.
l

Leland Richardson [G]

03/26/2020, 9:04 PM
In general there are a lot of avenues to improve dev experience here. Some that i know can help are below. Some of these I know we are working on already, but not all of them (yet?): 1. improving actual kotlin compiler speeds. there’s an entire team at google working on this in addition to jetbrains folks. There’s a new frontend that has shown some promising results here. 2. Improving compose plugin times. There’s some low hanging fruit here that should provide big wins as we haven’t optimized it at all yet. 3. gradle currently invalidates artifacts based on hashes of the results of their dependencies artifacts changing. This can be made smarter and only invalidate on public api changing. 4. for emulator, reducing time to hot swap and install app 5. improving the time it takes for gradle to check tasks for updates. this is problematic because of gradle’s model, but there might be some leeway we can make when running in a daemon and IDE only detects certain files changing. 6. incremental compilation for kotlin. This works already for example in JPS but not in gradle currently, but doesn’t seem to be any fundamental reason why it doesn’t. just needs to be wired up. 7. skip compilation entirely for changes to literal values in compose projects and just send update directly to the runtime. This is equivalent to the “instant rendering” zach was talking about with swift UI. 8. use kotlin compiler daemon and host it in the same process that the preview is running and use a dynamic class loader to swap classes and then recompose UI after changes. 9. tweak compose compiler code generation to produce more durable tree generation such that we could hot-swap refactored kotlin code and the bulk of the ui could recompose instead of being completely torn down and rebuilt every time. This is similar to “hot reloading” in react for example.
👍 4
g

gabrielfv

03/27/2020, 4:44 AM
That was a great answer, in fact I've come across a few things you mentioned (most of kotlin and gradle related issues). I see Compose needs a huge heap of work done since an UI framework for android is a huge deal, specially considering its long way until now. I have zero experience with contributing to Google repos or AOSP, but Compose is really something I'd like to lend a hand on, if it's possible.
l

Leland Richardson [G]

03/27/2020, 4:48 PM
yeah, this particular area (build+dev tooling) is probably one of the harder areas to contribute externally as it requires a lot of coordination and consensus across teams and separate products
once we get into a more mature state (alpha or beta), i’d like to spend some time making it much easier to contribute to compose. spending time improving the contribution workflow as well as documentation and organizing simple tasks that could help people be successful
right now it is fairly chaotic since things are changing so rapidly. sadly even though compose is OSS it is at the moment a pretty steep hill to climb to contribute. if you’re really eager though, there are definitely things.