Tech Review Series: Kotlin
In our final tech review series, we’ll talk about mobile development and we’ll start with Kotlin. Being Google’s preferred language for Android development, Kotlin is used to create native Android apps and is considered a more upgraded version of Java. So is Kotlin really better and what should you know about it? Let’s get started.
Kotlin: a brief history and the current state
Kotlin was first announced in 2011 by JetBrains, a Chezh software company that produced a number of well-known IDEs such as GoLang and PyCharm. The reason behind Kotlin’s creation was to come up with a new programming language for JVM that would perform on a high scale and with no issues, present with the existing languages. As well, Kotlin’s developers aimed for it to compile as fast as Java and they succeeded.
Even though Kotlin was announced in 2011, its first official release happened in 2016 only. Later in 2017, during its Google I/O, Google announced first-class support for Kotlin and in 2019, Kotlin became Google’s preferred language for Android development as we already mentioned.
Since its first release in 2016, Kotlin went from v1.0 to v1.4. The latest version was released in 2020, with v1.2 (2017) and v1.3 (2018) releases happening in between. Some of the most notable changes in the v1.4 version are multiplatform programming becoming an alpha feature (while being experimental before), coroutines for asynchronous programming, and light changes in support for Apple’s platforms.
Today, Kotlin is one of the most loved programming languages as per the Stack Overflow report by 2020.
Source: Stack Overflow
And since Google made it a preferred language for Android development, Kotlin saw a drastic growth in the last two years, gaining approximately 1.1 million developers. As for the companies using it, the list features such names as Netflix, Pinterest, Uber, Amazon, Trello, and Coursera. And judging from its users, Kotlin indeed is worth your attention in terms of performance and reliability.
Kotlin: technology type
Kotlin is an open-source, general-purpose, statically typed language that can be used for mobile and cross-platform development. It is known to be very easy to learn and very concise, especially if compared to Java. As well, Kotlin allows for functional programming as it supports anonymous functions, lambdas, higher-order functions, inline functions, and much more.
Kotlin is based on several principles that dictate its coding style and its core. These principles are:
- Readability: Kotlin aims to provide a concise code with maximal readability;
- Pragmatism: that means Kotlin is highly suitable for day-to-day development and allows developers to easily get the job done.
- Interoperability: this is one of Kotlin biggest selling points and it implies that Java libraries and frameworks can be used from Kotlin. Same, the Kotlin standard library can interoperate with Java.
When working with Kotlin, it is important to consider certain things about this language that are dictated by its principles. For example, there are certain areas that are constrained intentionally in order to aid readability. As well, Kotlin dismisses checked exceptions for better scalability and it focuses on toolability a lot. The latter implies that variable types are defined after variable names in order to eliminate unclarity during the parsing process.
Other Kotlin features worth your attention are:
- Coroutines for asynchronous programming;
- Collection filtering;
- Null safety;
- Sealed classes.
Kotlin and JVM
One of the best and most notable things about Kotlin is that it compiles to Java bytecode (like Java code) and is executed at runtime by the Java Virtual Machine. The JVM doesn’t know the difference — it receives and executes bytecode in the same way as it would for the code produced from Java, Kotlin, or other JVM languages.
The use of Kotlin: most common cases
Kotlin is a multi-purpose language and mobile development is not its only use case. Below are the most common ways to deploy Kotlin for your project.
Mobile development for Android
Though Kotlin can be used for cross-platform development due to its Kotlin Multiplatform Mobile feature, it truly shines when being used for Android apps development. As we mentioned earlier, Kotlin resolves certain issues that Java has and provides a pleasant and easy developer experience. Developers admit Kotlin to be concise (see above!) and clear and love the fact that it has syntactic sugar.
Kotlin works surprisingly well for web development and one of the most common stacks for Kotlin is Ktor and exposed. You can also efficiently combine Kotlin and Spring and it will deliver the same great results due to the maturity of Spring and dynamics of Kotlin. And don’t forget that Spring officially supports Kotlin since Spring Framework 5.0 which is another reason why you should try it.
Kotlin allows multiplatform development both for Android and iOS platforms. It enables developers to use a single codebase for the business logic of both iOS and Android apps so you’ll need a platform-specific code only where it’s really necessary. As well, if you already wrote some code, you won’t have to rewrite it to make it suitable for iOS. Instead, you’ll need to slightly modify it and you are good to go. And one more great thing about Kotlin: it doesn’t put any restrictions on the way you develop the app’s UI which adds to the flexibility of the development process.
Kotlin Pros and Cons
Even though some developers consider Kotlin to be a better and upgraded version of Java, Kotlin has certain limitations and considerations to keep in mind.
Kotlin is a fast-growing, compact, clear, and efficient language with a concise and intuitive syntax. It provides easy learning from the start, has a rich variety of great features, and it also allows migration from another language, if needed.
Kotlin saw a rapid increase in popularity after Google announced it as the first-class Android app development programming language. After this announcement, the majority of new Android applications started using Kotlin in production and not only for the development from scratch but also for the development of new features to be added to existing products.
It’s also worth mentioning that Kotlin Multiplatform and Kotlin Native increase the language’s role in the development environment, so it’s currently possible to build a full-stack Kotlin app. I believe that Kotlin has a big future and great potential and I highly recommend working with it.
Bogdan, Android Developer
At SoftTeco, we use Kotlin in many projects and we are really content with its performance. It’s quick, efficient, easy to understand, and offers a great developer experience.
In our next article, we’ll talk about Swift and iOS development. And if you have any questions left, comment under this article or contact us and we’ll gladly walk you through the mobile app development process.
SoftTecoView all articles by this author.