When we read the wikipedia description of the Kotlin programming language, it is stating that:
JetBrains lead Dmitry Jemerov said that most languages did not have the features they were looking for, with the exception of Scala. However, he cited the slow compile time of Scala as an obvious deficiency.[4] One of the stated goals of Kotlin is to compile as quickly as Java.
How did they achieve that goal? And why is Scala compile time so slow that it was unacceptable for the Kotlin creators? Or - in other words - which features of the Scala compiler make it slower than the Kotlin compiler?
Kotlin compiles directly to bytecode, but it does so much more efficiently than Scala does which means it is much more concise and performs better than Scala.
scalac's speed is bounded by two factors: It's a rather large program that runs on the JVM. So startup times are not great because one has to (1) start the JVM (2) load scalac into it (3) JIT compile much of it to gain speed.
Considering the job posting on these three platforms, amongst Scala vs Kotlin, Scala is the clear winner. 2. Functional Programming, While both these JVM languages are known for the functional programming paradigm, Scala is the winner between Kotlin vs Scala in terms of functional programming.
Since Gradle is the default for Kotlin, and with its daemon running and incremental compilation turned on, the clash between Kotlin vs Java performance, Kotlin compiles as fast or slightly faster than Java.
Although I think the question is not well suited for Stack Overflow as it will tend to produce primarily opinion based answers, here is one attempt: You have two different languages, especially concerning the type system, and two completely independent implementations of compilers. So to expect them to have the "same" kind of compilation speed is already a fallacy. I have linked in my comment to another question that examines the speed of the Scala compiler. Basically, it depends on many factors, for example the amount of work that the type inferencer and implicit resolution required by a specific code base.
Nevertheless, I ran a very quick example: I compiled some Project Euler solutions in Kotlin and Scala. This gave me for a fresh re-compile of the whole project:
Origin of the source code:
object pXY extends App { ... }
and placed it in a package euler
.Then I removed the files for which only one solution existed, ending up with 26 problems. Both projects were compiled with IntelliJ IDEA 15 CE using Rebuild Project
.
To give another perspective on this business, I ran wc
(word count) on the sources:
// lines words bytes
931 3603 33087 total // Kotlin
261 1166 6472 total // Scala
So now you can either argue that the Kotlin compiler needed to process "more source code" or that the Scala code was "more dense" :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With