https://kotlinlang.org logo
Title
i

Ion Carrera

03/06/2023, 4:17 PM
could anybody tell me if having a codebase of mixed java with kotlin, makes the project slower than having 100% kotlin codebase? why is that? do you have any link talking about this in more depth?
k

Kirill Grouchnikov

03/06/2023, 4:22 PM
Slower in what? Opening the project? Editing one source file? Building the project? Running one of the main methods you have?
i

Ion Carrera

03/06/2023, 4:22 PM
building + running basically
when I say slower, I could also say less optimal
k

Kirill Grouchnikov

03/06/2023, 4:24 PM
How are you able to compare it? Are you comparing two “similar” projects of yours? Do they have exactly the same number of source files, lines of code, complexity of code itself?
s

speshuric

03/06/2023, 4:24 PM
@Kirill Grouchnikov slower to hire developers 🙂
i

Ion Carrera

03/06/2023, 4:25 PM
let's say same complexity and same lines (I know it's a unrealistic escenario but let's think of it like that)
k

Kirill Grouchnikov

03/06/2023, 4:26 PM
Now you’re talking about a hypothetical scenario. Unless you have concrete evidence and numbers, there’s not much to be gained to discuss “feelings”
i

Ion Carrera

03/06/2023, 4:28 PM
I'm not saying it is slower, I'm just asking about this hypothetical scenario
k

Kirill Grouchnikov

03/06/2023, 4:28 PM
Yes, but what exactly are you asking?
i

Ion Carrera

03/06/2023, 4:29 PM
I have 100 classes, 50 of them in kotlin and 50 of them in java. Compiling it and running the whole code will be less efficient than having 100 classes in kotlin?
s

speshuric

03/06/2023, 4:34 PM
In fact the most negative effect of mixing Kava and Kotlin is "in humans". More resources to switch between codebases, non-idiomatic Kotlin code, some (documented) issues in Java-Kotlin interactions that will take your time. There is much more negative than hypothetical perf issues.
c

Casey Brooks

03/06/2023, 4:34 PM
Whether or not a mixed java+kotlin project is “slower” than pure Kotlin, it’s not going to impact it very much. I’d say this is a case of premature optimization: don’t seek to fix performance problems before you know whether it’s actually a problem. Just build your project in the way that makes it the easiest to read/write/maintain, and don’t worry about micro-optimizations like this until they actually become a significant problem for you. I’ll also add that in my experience, the build steps added to Gradle increase build times much more than having Java sources. The things that really affect build performance are build features like using many Gradle modules or Android build variants, code-generation tasks (especially KAPT; prefer KSP if you can), integrating with 3rd-party SDKs (especially performance monitoring tools), and writing your build scripts with features that disable Gradle’s ability to do project isolation and configuration caching.
i

Ion Carrera

03/06/2023, 4:40 PM
Okay thank you all for your responses
I wanted some post or link talking more into deep about java-bytecode generation about two different languages and their interoperability
but the idea I get, is that if there is any performance issue mixing the two languages, shouldnt be much