Software development as most of us know is a very fast-moving industry. New frameworks and languages are being developed all the time. Today I’d like to talk about a relatively new programming language Kotlin. Released in 2016, Kotlin had been in development since 2010 by JetBrains. Kotlin is a general-purpose programming language that is closely related to Java, even going as far as naming the language after an island just like Java was when it was created all the way back in 1995. Kotlin is designed to work in conjunction with the Java Virtual Machine (1). The Java Virtual Machine (JVM) is simply a virtual machine that allows any machine to run Java or Kotlin or any other JVM language by creating the framework of compiling your code into Java bytecode, a low-level code related to machine code, and then to machine code to be run on your machine.

Plainly put, Kotlin was designed to directly replace Java by being a better programming language but still retaining all the power and versatility of Java. The strong link with Java is cited as being another strength as it allows companies to make a gradual seamless transition from Java to Kotlin (2). Kotlin’s biggest advantage over Java is its conciseness. Kotlin can declare classes, declare data structures and solve many complex problems in one tenth the amount of code as Java. This allows programmers to code faster without being bogged down in the time-consuming realm of syntax. It also enables the creation of code with a much higher level of readability and inherently makes coding safer as it prevents programmers from making mistakes that are common in less powerful languages (3). Overall, conciseness and readability can be a huge advantage for individual programmers and companies alike. Another big advantage is that it allows coders who are new to the language to learn it much quicker than most other languages and allows experienced programmers to code much faster and efficiently giving an additional productivity boost to companies. In fact, for this very reason since the introduction of Kotlin into Android studio Kotlin has surpassed Java as the preferred language of Android app developers (1). Here is an example of Kotlin class creation vs Java.

As a software developer it is always exciting to learn about new technologies and languages. In my opinion always having the necessity to continue learning is one of the best parts of being a programmer. While I don’t think Java is going anywhere, Kotlin’s ease of use and the lack of 25 years of bundled legacy code, makes Kotlin an extremely appealing option for any savvy programmer. Overall, Kotlin is more of an iteration of Java, a step forward for an aging language, which is making a best effort to boil down the core principles and make a better language out of it.
If curious here is a long list of direct differences between Java and Kotlin from a great blog written by Vijay Singh (link to blog: https://hackr.io/blog/kotlin-vs-java)
Java vs Kotlin: Comparison
| Feature | Java | Kotlin |
| Checked Exceptions | Available | Unavailable |
| Code Conciseness | Can’t be labeled as concise | Better than Java |
| Coroutines | Unavailable | Available |
| Data Classes | Required to write a lot of boilerplate code | Requires adding only the data keyword in the class definition |
| Extension Functions | Unavailable | Available |
| Higher-Order Functions and Lambdas | Higher-order functions are implemented using Callables. Lambdas expressions are introduced in the Java 8 | Comes as one of the prebuilt features |
| Implicit Widening Conversions | Available | Unavailable |
| Inline Functions | Unavailable | Available |
| Native Support for Delegation | Unavailable | Available |
| Non-private Fields | Available | Unavailable |
| NullPointerExceptions | Available | Unavailable |
| Primitive Types | Variables of a primitive type aren’t objects | Variables of a primitive type are objects |
| Smart Casts | Unavailable | Available |
| Static Members | Available | Unavailable |
| Support for Constructors | Can’t have secondary constructors. Although, can have multiple constructors (constructor overloading) | Can have one or more secondary constructors |
| Ternary Operator | Available | Unavailable |
| Wildcard Types | Available | Unavailable, has declaration-site variance and type projects as an alternative |
Sources:
- https://kotlinlang.org/api/latest/jvm/stdlib/index.html
- https://www.jrebel.com/blog/interview-with-kotlin-creator-andrey-breslav
- https://business.udemy.com/blog/kotlin-vs-java-9-benefits-of-kotlin-for-your-business/
- Vijay Singh’s blog post: https://hackr.io/blog/kotlin-vs-java
Image 2: https://www.mediaan.com/wp-content/uploads/2019/02/Java_vs_Kotlin.png