louiscad
10/19/2020, 7:20 AMconst val
affect/hinder incremental compilation in ways plan val
don't, granted their value don't change, but something else changed in the host class (e.g. a new constant or property)?gildor
10/19/2020, 8:11 AMephemient
10/19/2020, 9:20 AMconst val
gets inlined at the usage site, so if you change them, all users do have to be recompiledephemient
10/19/2020, 9:21 AMstatic final
primitive and String fields in Javalouiscad
10/19/2020, 9:21 AMephemient
10/19/2020, 9:22 AMkralli
10/19/2020, 9:26 AMconst
has no affect on the incremental compilation in this particular case. There would be no change in the ABI of that property and therefor no cause for additional recompilation.louiscad
10/19/2020, 9:30 AMkralli
10/19/2020, 9:54 AMgildor
10/19/2020, 9:56 AMall users do have to be recompiled@ephemient I understand that it inlined, but my question: “all users will be recompiled” or “all modules which have this module in dependencies”. Because second is how it works on Java with Gradle, essentially constant kills any kind of incrementality, there is no mechanism to track who is using constant, every class which in theory have access to constant will be recompiled
ephemient
10/19/2020, 10:05 AMgildor
10/19/2020, 10:06 AMephemient
10/19/2020, 10:06 AMgildor
10/19/2020, 10:06 AMlouiscad
10/19/2020, 10:06 AMgildor
10/19/2020, 10:06 AMgildor
10/19/2020, 10:08 AMgildor
10/19/2020, 10:09 AMephemient
10/19/2020, 10:10 AMgildor
10/19/2020, 10:10 AMIs it any easier for fields or method calls@louiscad Yes, class level property doesn’t have such issues, because it not inlined, Gradle team recommends never use constatns
ephemient
10/19/2020, 10:11 AMlouiscad
10/19/2020, 10:11 AMconst val
for their dependency notations declared in buildSrc
should drop the const
keyword @gildor?ephemient
10/19/2020, 10:12 AM@kotlin.Metadata
annotationephemient
10/19/2020, 10:17 AMlouiscad
10/19/2020, 10:20 AMgildor
10/19/2020, 10:21 AMDoes it mean that all the folks usingI think buildSrc is another problem, any change in buildSrc cause full recompilation of everything, so const probably not worse than any other change (at least from 6.8 it only related to ABI changes)for their dependency notations declared inconst val
should drop thebuildSrc
keywordconst
gildor
10/19/2020, 10:22 AMI read that article as@ephemient I see you point, completely forgot about this optimization. But now returning to my question, how does it work with Kotlin compiler? probably it just doesn’t work
gildor
10/19/2020, 10:23 AMnot sure exactly what Gradle considers part of the ABI for KotlinIt’s not really Gradle responsibility, Gradle manages Java compiler, it’s part of it, but not Kotlin, all incrementallity for Kotlin is a part of Kotlin Plugin, not Gradle
louiscad
10/19/2020, 10:23 AMbuildSrc
as an example, but it's not my use case, I'm working on a Gradle plugin that provides constants to be used in the Gradle scripts.ephemient
10/19/2020, 10:24 AMgildor
10/19/2020, 10:24 AMephemient
10/19/2020, 10:25 AMgildor
10/19/2020, 10:25 AMgildor
10/19/2020, 10:25 AMthat same optimization should work the same for kotlin since that’s a property of the .class filesNo, I’m very doubt about it
louiscad
10/19/2020, 10:25 AMephemient
10/19/2020, 10:25 AM@Metadata
and compile avoidance play togethergildor
10/19/2020, 10:25 AMephemient
10/19/2020, 10:26 AMgildor
10/19/2020, 10:26 AMephemient
10/19/2020, 10:26 AMephemient
10/19/2020, 10:29 AMabreslav
10/19/2020, 11:08 AMlouiscad
10/21/2020, 8:24 PMconst val
, and got confused when I read that some parts of incremental compilation can still be improved.
I read parts of the blog post again, and it made more sense to me and I understood there should not be any impact regarding non changing `const val`s. Now, I discovered other reasons to use a plain val
for the use case I have, but it's great to see that const val
are not worse than val
if you know you'll never, or rarely change them and binary compatibility is not a concern regarding their value.