The Pros and Cons of Kotlin for Android Development
The Pros and Cons of Kotlin for Android Development
Read about some of the reasons developing your Android app with the Kotlin language is better for your developers, testers, and users.
Join the DZone community and get the full member experience.Join For Free
Probably one of the most important announcements made at Google I/O annual conference this year was the first-class support for Kotlin on Android. Similar to Swift for iOS development, Kotlin has brought up a number of questions. Above all, business owners who are running successful apps, and ones that are only willing to enter the Android market, want to know if it makes sense to use the newly adopted programming language over the traditional stack.
Specializing in Android development as one of the key technology domains, we at Eastern Peak want to help our clients make informed technology decisions. Having weighed the pros and cons of the Kotlin programming language, we have been able to source some valuable insights on the language, which we want to share with you. But first, let’s shed the light on the Kotlin’s early history and recent adoption trends.
What Should You Know About Kotlin? The Background Check
Kotlin is a powerful statically-typed programming language that runs on Java Virtual Machine (JVM). Built by JetBrains, the development company behind TeamCity, YouTrack, and a number of IDE solutions, the language is completely open source.
The language isn’t quite new: it was introduced back in 2011. However, the interest for Kotlin peaked a couple of months ago, following the announcement about its official support as first-class Android development language at Google I/O 2017.
As a result, the language, for the first time entered into the top 50 languages in June, according to TIOBE Index, over 30 positions up since May.
Now, thanks to solid corporate support from JetBrains and Google, the language is rapidly gaining adoption. According to the information on the official website of the language, some of the leading technology companies, including Atlassian, Pivotal, as well as giants like Uber, Pinterest, Evernote, are actively using Kotlin for their Android apps.
If you are considering joining the lineup, make sure you are aware of the benefits as well as possible pitfalls of this technology. Here are some insights into the Kotlin programming language.
The Pros and Cons of Using Kotlin for Your Next Android App
Judging by the some of the most recent feedback (and the standing ovation to which Kotlin was announced the first-class language for Android), developers seem to love Kotlin. Being positioned as a “better Java,” it offers a number of improvements as compared to its 22-year old predecessor. So, here are some of Kotlin’s advantages:
Increases Your Team’s Productivity
Being Java-based, Kotlin, however, eliminates the obsolescence and cumbersomeness of its predecessor. The language is compact, clear and efficient, it has a concise and intuitive syntax. As a result, Kotlin can significantly increase team productivity: It takes less time to write and deploy new code. This also contributes to better code maintainability at scale.
For example, converting the “App Lock” app from Java to Kotlin reduced the total lines of code by 30%, as reported by A. J. Alt, Android developer at Keepsafe.
Compatible With Existing Code
One of the strong points of Kotlin is its 100% Java interoperability.The language works well with Java itself, including all related tools and frameworks, which provides a rich ecosystem. Moreover, this makes it possible to gradually migrate to Kotlin, or to successfully use both languages within the same project.
Built and supported by JetBrains, Kotlin has a stellar support for a number of IDEs, including Android Studio. Using familiar and tried and true development tools also contributes to developer productivity and satisfaction.
Fewer Bugs (and Less QA Time)
With a more compact and clear codebase, Kotlin allows for less errors and more stable code in production. The compiler detects all possible errors at compile time, not at run time. This makes Kotlin a safer alternative for Java.
Unlike Swift, Kotlin is a mature language. Being introduced back in 2011, it has gone through multiple Alfa and Beta stages before its final 1.0 release. The latest release is also reversely compatible with the previous language versions.
However, there are several pitfalls to consider before going all in with Kotlin in production.
- Being very close to Java, Kotlin still differs in many aspects. Thus, a certain learning curve is involved for a developer who wants to switch languages. Thus, additional investments in training and time will be needed if you decide to move your Android development team to Kotlin.
- Some developers report slower compilation speed as one of the main drawbacks of Kotlin. However, the results of multiple tests are mixed: In some cases, Kotlin beats Java in compilation speed, but sometimes it is significantly slower than its predecessor.
- While Kotlin is rapidly growing in its adoption as the first-class language for Android, it still has a small developer community. This leads to limited resources for learning the language and makes finding the answers to any questions that might arise in the process of app development difficult. For example, searching for Kotlin on StackOverflow returns just over 3,600 posts tagged with Kotlin, compared to over 1,000,000 Java-related posts.
- As Kotlin is still relatively new to most of the developers, it might be hard to find experienced professionals in this domain. According to information on indeed.com, the number of job postings featuring Kotlin skyrocketed after the Google I/O.
While many companies are currently searching for Kotlin experts, the talent gap might soon become even bigger.
Kotlin vs Java: Is It Time to Switch the Language?
As you can see, there is no easy way to answer this question. While Kotlin clearly is superior to Java in some aspects, it is still far from being perfect. If you want to give Kotlin a try, you can hire a dedicated developer or allow some of your team members to experiment with this language. While it won’t show any tangible results to the performance of your applications, or to their UI, it won’t harm them either.
Published at DZone with permission of Valeriia Timokhina , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.