Not quite a surprise, but when you choose developers to work on your custom Android application, a certain technology they use is of the essence for you. The two most commonly used languages for Google now are Java and Kotlin (Now, it's official! Google made Kotlin a first-class language for writing Android apps), so for you, it may seem, at first, a matter of small importance what language your team’s coding on. Further consideration though shows that programming language might also cut down some of your time and expenses.
Originally, in the year of 2011 as an unveiled version, Kotlin first appeared as a new language for Java Virtual Machine from a team of Saint-Peterburg programmers called Jet Brains. The reason they decided to come up with a new “spinning wheel” for Android development is quite easy to understand; apparently, there are a few:
Java has been around for 22 years already (quite a term for a programming language), which is why there are loads of features that can not be implemented due to Java's massiveness and obsolescence.
Reasons to use Kotlin for Android go as follows:
It’s Android-focused. Kotlin was written by the same folks who created popular integrated design environments (IDEs), so its background comes from mobile industry pros who were looking for solutions to specific problems.
Switch from Java is extremely easy. In IntelliJ or Android Studio, converting Java files to Kotlin just requires installing the Kotlin plugin, adding it to the Gradle build files, and clicking convert.
Extension functions, which help in building really clean APIs and solve a bunch of other problems.
It has null in its type system. Nullability problems are common in Java, and Android uses null quite a bit to represent the absence of a value. Basically, having a null point exception can kill an app. Kotlin solves this by having null right in its type system, not forcing developers to use some kind of workaround.
Simple syntaxis. Less code to write. Java isn’t known for being the most succinct language, and while that isn’t a con in and of itself when you’re programming for Android and using a bunch of common idioms, a verbose code can lead to more chances for bugs. When you’re able to write less code (at least 20%) with a language that’s more concise, there are fewer opportunities for errors, and it’s less tedious for developers.
Type-safety language In Kotlin every class is a function, and vice versa; more to this, same as Swift for iOS, Kotlin for Android has Optional types, which help with all the safety checkups.
The Anko library and plenty of other Kotlin-based projects. The Anko library is a Kotlin source file that eliminates a few XML-related headaches, too. There are over 2000 Kotlin projects on Github, with everything from frameworks to build systems to libraries.
It avoids extra garbage collection, a common problem in Android development that adds inefficiency to Java code.
Switching between languages
The world we live in is getting quite unpredictable on many occasions, and in terms of mobile application development sometimes, there is a need to change the team you have been working with. Let’s say you used to work with outsource team, but now there is a request for an in-house development for your project. How difficult would it be to make a "translation" from one language to another? Back again, the answer really depends on the tech your previous engineers used. If we take a switch from Java to Kotlin as an example - then there undoubtedly is a solution. Jet Brains has created a Java-Kotlin converter which helps to resolve this issue; however, some errors yet occur during the conversion process, so it has to be monitored and some of the operations have to even be manually set.
On the downside, the conversion from Java to Kotlin would be yet more stagnant and painful, as not all the functions, methods and variables could be converted. Perhaps the quickest fix for the new team you cooperate with would be to continue writing in Java if possible.
Also, the possibility of conversion to another language would depend on the size of your project. There are, generally speaking, 3 types of projects: small, medium and large.
Small projects take around 160-200 hours, and if there is no complex architecture - then they can possibly be transferred to Kotlin;
Medium projects consist out of up to 5 month-length development and are pretty inconvenient to convert;
Large projects development starts from 5-month term and projects of this category are totally impossible to convert into another language;
Undoubtedly, Kotlin may have its pros and cons, but plenty of features became practicable once Kotlin came in. Unlike the Swift programming language, which was an internal Apple project and then open sourced later, Kotlin isn't owned by Google. The language will continue to be developed and supported by JetBrains — the company is partnering with Google to set up a nonprofit Kotlin foundation to shepherd the language.
Kotlin is the official Android language for future. A concise way to code for Android in a smarter way.