Is it worth measuring performance between Java x Kotlin applications?

Asked

Viewed 114 times

1

Going through the Google Developers documentation, I found something pretty cool like: Measure app performance with Android Profiler

But knowing that Java and Kotlin are interpreted by the JVM, I believe that the performance difference is not so great, because from what I saw between the languages, when the subject is speed, they lead in relation to writing (Functional Programming) by being faster that ends up accelerating the development of the application.

With this, someone here has already gone through this and came to perform these types of measures (CPU, Memoria)?

  • I’m not sure but I believe that’s right, as both languages are compiled to bytecode (so the two can be used together) there is no, or at least almost, difference in performance

2 answers

3

Measuring performance is always interesting when you realize it should be faster. And performance changes depending on a number of factors. The same code can give differences.

A considerable amount of Kotlin libraries are different from those used in Java. Writing code in a certain way in Java and playing in Kotlin can cause a performance problem since they are different philosophies, with very different compilers.

Of course, in most cases there will be little difference, but there are cases that do not. That is, only measuring to see :)

I don’t know what you mean by functional programming, Kotlin has very little, only a little more than Java, but this can help the performance in some points and be bad in others.

  • "[...] when the subject is speed, they lead in relation to writing (Functional Programming) [...]" because from what I saw, Kotlin tries to bring more pro programmer the custom of using Dual functions etc.

  • This is just a point of the paradigm, and little important, and Java has tb and uses more and more. Lucky for us you didn’t have before, so was born the C#.

0


My personal opinion, as a very strong Java user throughout my career as a programmer, which today migrated to almost 100% Kotlin:

There is no significant difference in performance. I have no data to prove this, however, applications Android programmed in Java that were converted to Kotlin without thinking of performance, simply rewriting code to the most Kotlinistic language worked perfectly the same.

Moreover:

There’s no need to worry so much about performance unless it’s a deterrent. As a rule, a user will not even notice that the screen has loaded in 1 second, and not in 0.6667 second (most performative option possible). Or that its complete algorithm, which is not performance critical, took a second longer.

Don’t Optimize Your Code Prematurely. If you don’t have performance issues, and your code won’t be critical in performance, you don’t have to think about the performance difference.

Browser other questions tagged

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