Kotlin is here, and it is now an official programming language for Android development, alongside Java. Swift, the newest mobile programming language created by Apple, has been built to replace Objective C, the previous mobile programming language created by Apple.
However, Kotlin was not built by Google. Moreover, its declaration as an additional official language for Android development alongside Java embodies Google's philosophy.
Unlike Apple, which strives to replace its old programming language, Google takes a different path - it lets us choose.
How did Kotlin get there?
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 encourage everybody to embrace Kotlin but be careful when doing so. Let’s keep writing great code, even in new unexplored lands.
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?).
Written by Timor Surkis: https://email@example.com