On 17 May 2017, Google announced their first-class support for Kotlin, which means that Kotlin became an official language for Android app development.
Since then, JetBrains proved that Kotlin can also be successfully used for writing iOS apps – the official app of KotlinConf 2017 was built entirely in Kotlin and supported iOS, Android, as well as most browsers via its web app.
Support for Kotlin announcement (source)
With growing support for both major mobile platforms, Kotlin is bound to gain in popularity, and its future seems not to be confined only to Android. You might have heard about Kotlin and asked what it is and whether it is worth choosing this technology over Java for Android mobile development.
This article was written to provide answers to these questions - and more.
Kotlin is a statically-typed open-source programming language generating code that can run on the Java virtual machine. It was developed by JetBrains. Its name comes from the Kotlin Island which is situated near St. Petersburg, Russia.
While the syntax of the language is not compatible with Java, which was commonly used to develop apps for the Android platform, it can interoperate with Java code. In other words, code written in Kotlin works with Java as well as it does natively.
Kotlin uses aggressive inference to determine the types of values and expressions if they were not clearly stated. It makes the language even more distinctive from Java, which sometimes requires repetitious type specifications.
Despite being introduced back in 2011, it has grabbed the interest of the global community immediately after the announcement about being officially supported as a first-class Android development language.
Frankly speaking, leading tech companies like Atlassian, Uber, or Pinterest had started using Kotlin for Android app development long before it was officially supported.
If you want to join the group of innovators, you should learn about the advantages and disadvantages of this technology before using it for your app.
Kotlin is a powerful, modern language with many useful features. It’s very expressive and much more concise than Java.
While Java has earned its reputation as a robust and reliable technology, it lacks many features and is slowly becoming obsolete, making Kotlin a great candidate to replace it.
Kotlin is very similar to Apple’s Swift in terms of its ideas and goals. The similarities between these two languages will help Android and iOS developers easily switch between development for each platform.
When it comes to strictly technological advantages, Kotlin offers first-class support for functional programming, even though it is mainly object-oriented, making the most out of both paradigms and opening new programming possibilities.
Apart from that, JetBrains built protections against errors related to nulls straight into the type system, which makes the language much more fault-proof and thus easier and cheaper to maintain.
The creator of null famously said that the null reference must have generated billions of dollars in losses caused by errors, vulnerabilities, and system crashes. Now, you can stop fearing null-related errors and save yourself some money, too.
Apart from Android (and recently also iOS), Kotlin is also great for JVM development, which facilitates building desktop, web, and backend server applications using established Java frameworks such as Spring, Vaadin, Spark, Hadoop etc.
Learning Kotlin will give you a universal tool that you’ll be able to use for all kinds of development.
It is also worth mentioning that Kotlin is still under heavy development, so we can expect it to improve over time. Some time ago, JetBrains announced the first release of Kotlin Coroutines - a Kotlin library for asynchronous programming. Thanks to Coroutines, developers are able to work with asynchronous code more easily than ever.
Language creators are also experimenting with Kotlin/Native, which compiles Kotlin code to native binaries. It will allow us to develop applications for Linux, Windows or macOS.
But there is even more - the JetBrains team is working on Kotlin Multiplatform. It is exciting news because thanks to this technology we will be able to develop multi-platform applications with shared codebases (for example Android and iOS apps). As you can see, the future looks really bright for Kotlin development companies.
It seems like Kotlin has become loved by mobile developers, who now prefer it to its elder counterpart - Java. Here is a list of Kotlin’s most prominent benefits:
Being rather clear and compact, the language increases team efficiency thanks to its succinct and intuitive syntax. More work can be done as it takes less time and fewer lines to write and deploy working code.
Kotlin is positioned as a 100% Java-interoperable programming language. It is consistent with Java and all related tools and frameworks, which makes it possible to switch to Kotlin step by step. In case your product cannot be written in Kotlin only, both languages can be comfortably used at the same time.
Kotlin is supported by a vast majority of IDEs, including Android Studio, and other SDK tools. This helps increase developers’ productivity, as they can continue to work with the toolkit they are used to.
Kotlin offers a much more clear and compact codebase that makes the code in production more stable and consistent. Bugs get detected at compile time, so developers can fix errors before runtime.
Nothing is perfect, and neither is Kotlin. So don’t rush to use it in production before considering its disadvantages:
Sure, they are similar, but at their core these are two different languages. Developers won’t be able to quickly shift from one to another without taking some time to learn Kotlin. Therefore, if you consider changing your company’s approach to Android app development, it will require additional expenses on training the team.
In some cases, Kotlin is faster than Java - mostly when performing incremental builds. But still, we should remember that Java is the winner when it comes to clean builds.
The demand for specialists has abruptly escalated after the announcement of Kotlin getting adopted as a first-class programming language at Google I/O, but still there are more Java programmers on the market.
As you can see, there are no reasons not to switch to Kotlin. Still, you can give Kotlin a try right now and let your developer crew gain some experience in using a more advanced tech stack for Android app development.
If you’re currently using Java to develop your Android app, fear not, because nothing will change.
Google will continue to provide great tools and resources to make Java app development easier and faster. You can also add Kotlin to your app without worrying about future support. Check out Google’s official guide on how to get started with Kotlin development for Android.
Since Kotlin is 100-percent interoperable with Java, you can incorporate it seamlessly into your existing app, and you won’t even need to rewrite any Java code – just start coding in Kotlin right away!
That said, we would still recommend converting the app to Kotlin for a number of reasons.
Being more fault-proof, the app will become easier and cheaper to maintain. Kotlin also facilitates faster development because it is much more concise – rough estimates show that it can cut as much as 40% lines of code compared to Java.
Fewer lines of code = less time spent on coding = less money spent on development. Oh, and there’s an automatic Kotlin-to-Java converter, too, which you can find here.
Kotlin is also becoming more and more universal, so you will be able to transfer your app from one platform to another if need be. Lastly, the framework is new, efficient, and exciting, which attracts good developers.
We’ve already noticed it at Netguru – we’ve been getting lots of really interesting CVs from developers who want to program in Kotlin.
In the Android development world, it seems very likely to happen. Google is now treating Kotlin as a preferred programming language for Android.
Official support from a giant like Google is a big step towards making Kotlin as popular as Java (or even more so). But let's not forget that Java is not only used on Android - its ecosystem is really huge and it will probably take a lot of time for Java developers to adopt Kotlin for all of their products written in Java, which often won't make sense from the business perspective.
It is safe to say that those languages will be used together for a pretty long time.
You don’t have to hurry to replace your regular tech stack with Kotlin and other novelties. Try baby steps instead! If you have an existing Java application, try to write your next feature in Kotlin. This will allow you to get familiar with it without the need to rewrite the whole project.
We have already begun introducing this technology. All of our new projects are written in Kotlin and our developers are extremely happy with it. At the same time we are not planning on dropping Java right now, as we are still working with it on several of our projects.
If you have questions regarding the tech stack for Android app development, drop us a line. Our team will be glad to hear you out and think up a solution matching your needs.