What makes Kotlin a language faster than Java?

Asked

Viewed 961 times

11

I have read in some articles that Kotlin is faster than Java, but none of them exemplifies why.

What can be seen at first would be the question of the number of lines of code to perform such procedure or action. The Kotlin apparently reduces these lines (visually) compared to Java.

It would even be the reduction of bytecodes or would you have something special to make it faster? What makes it Kotlin a language faster than Java? If you have Java code inside the Kotlin, because of interoperability, or vice versa, this means that it uses the middle ground in relation to time?

  • There’s no right answer to the subject. Kotlin is a different language from java, more modern and simplified, in terms of comparison we can compare Objective-C (Used for IOS) and Swift, both languages reach a specific result but Swift is the future, for being more simplified, expressive in terms of code and thus increases productivity. Java is a language that few like it on android so far was the only option but surely this should change just as it happened on IOS. At the moment the ideal is to study both but certainly Kotlin is the future of android.

  • 2

    Quote where you say that 'cause it’s news to me.

  • @bigown just for that. I even went so far as to mention this the question of being faster, which I remember that even you questioned yourself. Then I wondered myself by such a definition. What I would like to know is if it really is faster and why?! If it really is?.

  • I don’t think I have to answer because the answer would be the question part of a wrong premise.

  • As received several positive and no one thought it should close I resolved to answer, the answer is not good, but the weak question with so little sense receiving several votes should indicate something.

  • 2

    Interesting because none of the articles you cited says it’s faster. They say tão rápido quanto

  • @Brunocosta hmmmmmm... got it.

Show 2 more comments

1 answer

10


Programming languages do not have speed. At most implementations have speed, yet it depends on a number of factors. Libraries are often a much more important performance factor.

I can’t think of a reason why Kotlin should be generically faster. It may occur at some specific point that Java implementations or the specification requires more inefficient code.

The Java library is used in Kotlin, so the performance is the same. It is certain that there are some specific implementations of the library for Kotlin. In general the gain is to be more suitable for use with Kotlin, but there may be some gain as well, but I wouldn’t call this language gain, because that can be used in Java as well.

Newer compilers and developed by a smaller number of people tend to generate less efficient code than more popular ones, so again Java tends to be faster.

Visual amount of lines doesn’t mean much for measuring speed. In fact tends to occur the opposite and fewer lines can mean less speed because it may be hiding something that manually the programmer could do more efficiently.

Here I will speculate, but it may be until the code generated for Kotlin hinders JVM optimizations.

The question starts from a wrong premise.

As a complement to my experience is that the Kotlin compiler is very slow.

After the answer the question was edited with quotations.

  1. It’s written so fast, not faster. Misinterpretation.
  2. At no time does it say that the language is faster. It says you should compile quickly, which is something else, and it doesn’t say it’s faster than Java, yet my experience is that the compiler is much slower. Misinterpretation.
  3. It talks very generically about incremental compilation, nothing else. Misinterpretation.

Kotlin’s premise to be faster than Java seems to be an unsubstantiated inference from the author.

  • 1

    Makes perfect sense.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.