What distinguishes Kotlin from Java?
Two popular languages that have influenced each other over the past years. How do they differ? When does one choose one over the other?
There are many programming languages, and sometimes it can be difficult to distinguish between them. Java and Kotlin are two that have been popular for quite some time and are often mentioned in the same breath. But what is really the big difference between them?
Java as a programming language: Write once, run anywhere
Java is a programming language that was created in the mid-90s by Sun Microsystems and became very popular very quickly. At that time, developers had to write code for a specific hardware at a time. If you wanted to run the same software on different hardware or another operating system, you had to adapt the code.
Led by James Gosling, Sun introduced its revolutionary Java Virtual Machine (JVM). It sits between the program code and the operating system. The JVM handles the translation of program code into machine instructions. This allows developers to write their code once and run it on different platforms without any modification whatsoever.
Java and its community grew very rapidly during the 90s and 2000s, and Java quickly advanced to become one of the most used programming languages in the world. Currently, there are an estimated 8 million developers who are proficient in Java.
Java as a platform: a good breeding ground for new languages
Java's virtual machine operates according to an open and well-documented specification. This led programmers to start experimenting with whether they could develop their own programming languages.
The developers began to port existing programming languages to the Java platform. In 2001, Jython was released and suddenly it was possible to write Python programs that could run on all kinds of devices. That same year, JRuby was also released, which did the same thing for the language Ruby.
But entirely new languages also emerged. In 2003, Groovy was released, a dynamic and object-oriented programming language. In 2004, it was time for the launch of the programming language Scala, which combines object-orientation with functional programming.
Java, the sloth among programming languages
Many of the new programming languages were created by frustrated Java developers. For the creators of the Java language, it was important to maintain backward compatibility with new versions of Java. This meant that they limited the number of new features and language concepts in each new version. At the same time, they never removed old language features. This caused the development of the Java language to stagnate, and developers began to create their own programming languages.
Kotlin, a breath of fresh air in the Java jungle
2011 was the year for Kotlin to make its debut. The software company JetBrains had been working on tools for Java developers for a long time and decided to create their own language. Many Java developers who were already using JetBrains products quickly took notice of Kotlin. Kotlin surprised with a programming language that resembled Java but was much more user-friendly. With the help of Kotlin's new language concepts, programmers could write code in a more powerful and readable way.
The breakthrough for Kotlin 📈
Slowly but surely, Kotlin made its way into all areas where Java was already present. Google's operating system Android was a platform where more and more developers switched from Java to Kotlin.
In 2017, Google announced at its developer conference Google I/O that Kotlin would become an official programming language for Android, alongside Java. This gave Kotlin a significant boost and many started using the language in their Android projects.
Why do we use Kotlin?
At Future Memories, we prefer Kotlin over Java. We find that Kotlin is more readable for developers. This makes it easier to understand someone else's code, whether it's for an Android app or a backend application.
Kotlin is 100% compatible with Java and it works excellently to mix Kotlin code with Java code. This means that we can still make use of the rich selection of the entire Java ecosystem with all its libraries, frameworks, and SDKs.
We have some applications that perform heavy computations in Kotlin. Fortunately, Kotlin offers so-called Coroutines, a very simple and powerful way to parallelize computations. With the help of Coroutines, we can reduce jobs that take several hours to just a few minutes.
However, it is noticeable that Kotlin is built on the Java platform. Starting up a Kotlin application takes as much time and consumes as much memory as starting up a Java application.
When it comes to creating small applications that start up quickly, we think the programming language Go is much better suited. However, if one is looking for robust cloud services that can handle a lot of traffic, we would probably choose Kotlin on the reliable, battle-tested Java platform.