https://kotlinlang.org logo
Title
d

David Herman

02/18/2022, 8:24 PM
I notice Compose for Web API uses
inline
quite a bit more than I'd expect. Is that to reduce the final javascript bundle size?
If this is to reduce the final binary size, then 1. If I'm writing a Compose for Web library, should I try to follow this pattern? 2. Is this a temporary limitation? Is tree shaking going to come for Kotlin/JS sooner or later?
b

Big Chungus

02/18/2022, 8:49 PM
If anything, inline bloats the bundle size. Main benefits of inline functions are runtime performance.
es6 support is on the roadmap, but suspended until IR backend is stable.
d

David Herman

02/18/2022, 8:51 PM
Are these premature optimizations then? I can't imagine setting css style properties are something that is happening in a tight loop or in large volume. Maybe concerns about startup time?
b

Big Chungus

02/18/2022, 8:51 PM
HOWEVER, using inline with unsafeCast saves bundle size as end result is pretty much 0 as opposed to creating an entire new function just to change compile-time type.
d

David Herman

02/18/2022, 8:52 PM
Ah ok so sometimes it does, gotcha
b

Big Chungus

02/18/2022, 8:52 PM
Kotlin.js has quite a few "special" functions in stdlib that are not real functions but rather hints for the compiler.
👍 1
d

David Herman

02/18/2022, 8:54 PM
Ok thanks, I see
I think in the cases I linked to above both ultimately delegate to unsafe cast so it's probably that happening here
Thanks for the info!
b

Big Chungus

02/18/2022, 8:55 PM
I'm sure JB guys didn't just do things randomly 😀
d

David Herman

02/18/2022, 8:56 PM
Me too, but I didn't understand why and wasn't sure if or when I should be imitating it
🤝 3