Você está na página 1de 3

KOTLIN VS JAVA

Vulnerabilities of Kotlin in comparison to Java for Android Development

1) Slow compilation
Small project (~100 classes in total, mostly in Kotlin) takes ~1 minute to assemble.
This is simply unacceptable. https://youtrack.jetbrains.com/issue/KT-6246

2) Performance of Kotlin plugin for IDEA


Syntax analysis and highlighting of Kotlin in IDEA (Android Studio) pretty often
freezes development machine during typing, unacceptable.

3) Problems with annotation processing


Sometimes it gives random errors and you have to do clean. Almost every day I see
complaints about that on different resources. I'm not alone.

4) Mocking Kotlin classes with Mockito is painful


Almost everything is final in Kotlin by default: classes, methods, etc. And I really like
it because it forces immutability -> less bugs. But at the same time, it makes mocking
via Mockito (which is kind of gold standard in JVM world) painful and goes contrary
with language design.
Yes, PowerMock is possible solution, but it interferes with tools like Robolectric and
generally it was always a good rule that you should not mock final classes and final
method.
I understand that in Java we have that problem of everything non-final by design,
but at the same time I don't want to change code just for testing.

5) No static analyzers for Kotlin yet


Yes, kotlinc adds more safety to the code than javac, but if you want to achieve good
performance of the compiler you don't want to turn it into static analyzer.
Static code analysis is good for CI, but probably you don't want to run it every time
you click on run button in IDE during local development.
Java has: FindBugs, PMD, Checkstyle, Sonarqube, Error Prone, FB infer.
Kotlin has: kotlinc.

6) == does equals() instead of reference comparison


If Kotlin is "better" Java or "Java on steroids" then it should be better, but
not breaking.
Imagine you're in the process of rewriting Java project to Kotlin, you will have Java
and Kotlin code at the same time.
You'll have to read and write same code that works differently from language to
language. This is one of the reasons why I don't like Groovy.
7) In bad hands operators overloading may lead to bad results
Statement 1: you will need to deal with old codebase written in Kotlin in future.
Statement 2: you can add operators overloading to existing java classes via
extension functions.
Now imagine you see something like val person3 = person1 + person2 in already
written code you need to deal with.
Every project you'll work on may have its own meaning of operators for same
classes

8) Everyone in the team needs to learn a new language

9) Hard to find developers with Kotlin experience

10) Kotlin is entirely not backed by Google


This is true, but Android relies on byte code. And the byte code from Kotlin and Java
will be in the end the same thing. We are only talking about the language we are
writing the code in. Google just dismissed the Jack toolchainand confirmed
supporting javac compiler for Java8 support. So a bright future here.
The true question you need to ask here is, if JetBrains backs up Kotlin for Android.
Happily, they totally are committed. Its a big success story and lots of effort goes in
here. Last time a canary(!) build of Android Studio broke something with Kotlin
support the next day the fix in the Kotlin plugin was available.
Edit: actually Google is already using Kotlin themselves! Check out the databinding
compiler for Android. Thanks ubo Mudrk for pointing that out.

11) Its too risky to put Kotlin in a production app.

12) Its just another JVM language

13) A new language slows us down

14) An app built with Kotlin will likely result in a larger file package size than
one built purely in Java.
Thats because Kotlin has its own standard library thats added on top of Javas
standard library. Also, the build time for Kotlin is a little slower using Gradle, which
can be frustrating. Though Gradle is also slow using only Java, its not quite as slow
as with Kotlin
REFERENCES
1. https://artemzin.com/blog/why-i-dont-want-to-use-kotlin-for-android-
development-yet/
2. https://hackernoon.com/kotlin-in-production-should-you-stay-or-should-
you-go-a3428b44b236
3. https://android-developers.googleblog.com/2017/03/future-of-java-8-
language-feature.html
4.

Você também pode gostar