This message was deleted.
# kotlin-dsl
s
This message was deleted.
👀 4
l
Hi Ben, This topic will be a focus for the 8.x development line where Gradle intends to make improvements to Kotlin DSL build script compilation performance. 8.0 already starts with improvements, more to come. Currently, for raw script compilation performance, Groovy DSL is still ahead. However this impacts mostly very large projects when doing build script changes. For regular development use cases - working on project code - caching (regular and configuration one) levels the playing field. The main benefit of the Kotlin DSL is the way it helps discovery of Gradle types and extensions, when used with IDE support. If you are learning Gradle or discovering some plugins, go ahead and use it.
🙏 1
v
Or for helpful error messages when you mess up the syntax. 🙂
2
b
@Louis Jacomet thanks for the info. from what i gather, with 7.x, there's no good reason to switch over to kotlin for performance. i will keep a look at the 8.x changes.
do you have up-to-date performance metrics for the use cases you mentioned above?
m
My hunch there is that Kotlin will never be faster than Groovy. Best case, it's maybe going to be in the same range once K2 ships and Kotlin compiles faster. But the Kotlin compiler does more stuff (type inference, type checking and what not) so it can't really beat Groovy. So as others said, I wouldn't switch just for performance but there are other very compelling reasons to switch (autocomplete, type safety, ...)
p
That's correct, the Groovy compiler is so permissive that it'll be very difficult to be as fast. For example GroovyC doesn't even do compilation warnings, it simply cannot.
There's one case where Kotlin build logic can outperform Groovy. It is not about compilation but actual evaluation of the build logic. If your logic extensively uses Groovy dynamism it'll have to resort to reflection and "method missing" semantics. And that is slow. With Kotlin you don't have this option. If you use Groovy
@CompileStatic
then you can´t rely on dynamism anymore and evaluation performance would be very similar.
👀 1
The Gradle Kotlin DSL has a couple advantages over the Groovy DSL when it comes to avoiding script compilation though. Script compilation supports compilation avoidance. The compiled scripts are stored in and loaded from the (remote) build cache.
m
I always wonder about that last part actually. How come this is not possible with Groovy? Run the Groovy compiler and turn build.gradle into a .jar that is stored remotely?
p
It is possible, it's just not implemented (yet?)
👍 1
m
Gotcha 👍
p
Same for compilation avoidance
As I commented it's not looking great. We have room for improvement and plans we will implement this year though.
m
Dang! Is this because the 1.8 compiler is slower?
t
why abi change became slower? 🤔 Groovy became faster as well. Kotlin DSL looks little faster as initial measurement
p
Comparing build duration against previous measurements doesn´t make sense. Comparing the ratio does.
Groovy got faster after some Groovy upgrade yes
t
I wonder if script compilation could reuse new IC from Kotlin/JVM for abi changes 🤔
p
The gap is not just the Kotlin compiler performance change. There are also some changes due to other areas of Gradle at play. But there definitely was a performance regression with 1.8 in our isolated tests. We are discussing this with the compiler team and will try to mitigate.
thank you 1
Yes, IC is one avenue we need to explore.
👍 2