Android Developers — This Is Why You Need To Be Wary With Kotlin

T.Surkis
AndroidPub
Published in
3 min readAug 7, 2017
Just as one will pay attention when entering a road after seeing the sign, so should you when using a new language. Credits belong to https://www.instagram.com/cinamon357.

History

The Java language was built to write once run anywhere. Instead of compiling directly to machine code it compiles to bytecode, and afterward, the JVM translates the language to machine code. This approach allows the hardware to become an abstract layer, freeing the developer from keeping it in mind when developing programs.

When the Android operating system was open for development back in 2009, the programming language to build Android applications was Java.

Fast forward to 2011, JetBrains unveils the Kotlin programming language. Even though it took JetBrains to release the 1.0 stable version of Kotlin 5 years, it caught the Android development world’s attention with its approach to solve the verbosity and problems of the Java programming language.

Followed by hysterical applauds from the crowd, in 2017 Google declared the Kotlin language as a first class language for Android. Even though many would argue that Kotlin was ready for companies to use in their production code since version 1.0, it was the announcement of Google that made it an official companion\alternative programming language for Java.

Why did Kotlin succeed?

The language was aimed to be a JVM language. As a result, it could communicate with Java and vice versa. Combined with the great syntax to save us from writing the same code in a million lines of Java, it was ready to use in Android development from day one.

It would take some time for companies to make the switch and until then it is our responsibility as Android developers to study the language.

Beware of Kotlin

With the said above, Kotlin needs to be treated carefully. As I mentioned earlier, Kotlin is a JVM Language. As a result, the bytecode can be reverse engineered to Java code. That means that the beautiful syntax of the Kotlin class you write becomes a plain Java class.

Therefore, it is our responsibility to be careful and aware as to what our Kotlin code creates. We mustn’t rush to write a great looking Kotlin classes and marvel at their sugary syntax. We must be aware, in every step of development of what our code looks like behind the scenes. Because, as we all know it — a poorly written Java class can cause problems and issues, if not now then later down the road.

I highly recommend the following articles that explore the hidden costs of Kotlin:

Conclusion

I encourage everybody to embrace Kotlin but be careful when doing so. Let’s keep writing great code, even in new unexplored lands.

Personal Thoughts

I am only now starting to study Kotlin myself, but I see the potential of it. I believe the day is not far when most of Android applications would contain at least some Kotlin code (if not 100%).
Maybe one day when Google will release Fuchsia, given its history with Oracle and the development of Kotlin native, we will see an operating system not dependent on Java (one can dream, right?).

Click the ❤ button to let me know if you enjoyed the article and follow me on Medium and Twitter.

--

--

T.Surkis
AndroidPub

A Flutter developer by day, a technology enthusiast by night.