Why Kotlin is eating Java [Storytime Saturdays]
We've seen more and more big companies and groups push towards integrating Kotlin into their workflows.
Hey, it’s your favorite cult leader here 🐱👤
On Saturdays, I will cover stories/writeups covering various people’s experiences 📚📚. These stories will help you learn from the mistakes and successes of others. These stories will cover various topics like Leadership, Productivity, and Personal/Professional Development. Use these to zoom ahead on your goals 🚀🚀
To get access to all my articles and support my crippling chocolate milk addiction, consider subscribing if you haven’t already!
p.s. you can learn more about the paid plan here.
Some of you are definitely squinting your eyes very hard at me right now.
But trust me, that title is not clickbait. Java, one of the legendary programming languages might be in danger of being replaced. And not as much by C#, as MS had hoped, but by an upstart language created by an IDE company. Kotlin, which was created to be an Android programming language, has now expanded into more. Its multi-functionality and great design have seen multiple organizations implement Kotlin into their systems.
Take a look at these two results. One from the StackOverflow programming languages survey-
According to the Stack Overflow developer survey 2019, Kotlin was the 4th most loved language (while Java was amongst the most dreaded)[7]. It maintained that in 2020 [8], was the 14th most loved language in 2021 [9], and number 11 in 2022 [10]. It has maintained a solid 60% rating throughout this period [7][8][9][10].
And another from Google itself
Kotlin is being expanded to more than just Android Development. Thousands of Google engineers are writing Kotlin code, and our internal codebase contains more than 8.5 million lines of Kotlin code to date. This number has been increasing rapidly as well, doubling year over year[4].
This is not a trend you want to ignore. In this post, we will cover a few things-
Why Google Initially chose Java as the language of choice for Android.
What made Java a bad programming language (take notes here).
What makes Kotlin so popular with so many organizations. We’ll go over the experience of developers at various groups, including Tech Giants Google, and Uber.
How Kotlin is expanding beyond Android development into other platforms.
As a tech professional, you don’t want to miss this. Whether you’re a student/person looking to transition into tech, a developer who wants to upskill, or a tech leader trying to keep tabs on the trends of the industry, the ideas discussed today will be very relevant to you.
Key Highlights
Why Google picked Java for Android- Unlike the iOS, Android phones don’t have one developer. There is a lot of variety in the phones running it. This means that the language used to build on the Android Ecosystem would need to be versatile. The programming language for Android also needed native support for OOP, as developing applications with GUIs without OOP is very difficult. Finally, the language of choice would need to be a popular one because Google wanted to attract as many developers as possible to their new mobile platform. This made Java a clear pick for Google.💕💕
Why Google dumped Java 💔💔- Java has many disadvantages, including slow compilation time and slow work of the JVM, ineffective memory management via garbage collection, no support for any kind of procedural code, and awful implementation of concurrent programming. There was also that Oracle lawsuit against Google, which caused Google to start shopping around. Jet Brains saw this opportunity and swooped in.
What makes Kotlin special- It requires fewer lines of code, is safer, has better threading, and more. This has led to mass adoption at Google and a push from Uber devs to migrate to Kotlin. We'll cover more data in the article.
Why Kotlin’s entanglement with Java matters- Kotlin is interoperable with Java. This is a huge plus, one that has lea to its success. Migrating software projects is expensive. Because Kotlin can be run with Java, changes can be made incrementally, making the transition much easier. Ironically, Kotlin’s compatibility with Java is one of the biggest selling points for people replacing Java with Kotlin.
Let’s get into the details.
Origins: The Love Triangle between Kotlin, Java, and Android
Kotlin was created because of the reasons discussed in the first 2 highlights. JetBrains started the development of Kotlin in 2010 and made its official 1.0 release in February of 2016. Kotlin was created because, at the time, none of the available JVM languages had many features needed for Android development. The lead developer, Dmitry Jemerov, noted that Scala was close to what they wanted, but had very slow compile times. Jetbrains’ goal in developing Kotlin was basically to make a language that has features similar to something like Scala with a fast compilation time [13]. From a business perspective, JetBrains also aimed to attract more people to use their development tools by facilitating Android development [15]. Because they wanted people to provide people with a product that gives users better tools and makes Android development easier, they gave Kotlin more focus on flexible abstraction, code readability, clarity, and backward compatibility [14].
Ever since its inception, Google has been in love with Kotlin. Kotlin has steadily become a more consistent part of the Android Development ecosystem. In 2017, Google officially announced that Kotlin would be added as an officially supported Language to Android [6]. Since then more and more developers have embraced Kotlin. In 2019, Google took the next leap and announced that Android would be Kotlin first.
“Kotlin is an expressive and concise programming language that reduces common code errors and easily integrates into existing apps. If you’re looking to build an Android app, we recommend starting with Kotlin to take advantage of its best-in-class features.” [1]
This push is more than just words on a screen. Not only did Google update all the documentation to include Kotlin, but they also pushed new Android Development courses in Kotlin. They “released two free video learning courses in partnership with Udacity: Developing Android Apps in Kotlin and Advanced Android in Kotlin. This content was also released as the Codelab courses Android Kotlin Fundamentals and Advanced Android in Kotlin, for those who prefer text-based learning” [5]. High-quality courses (especially those endorsed by established names like Google) lead to higher adoption and acceptance of frameworks/technologies. As of December 2019, nearly 60% of the top 1,000 Android apps contain Kotlin code[5].
This mass adoption is not a coincidence. 67% of professional developers who use Kotlin say Kotlin has increased their productivity [1]. In an internal survey at Uber, 95 percent of mobile engineers said that they would be willing to accept slower builds if they could write their code in Kotlin [2].
So what makes Kotlin so special?
Why everyone is swooning over Kotlin
One of the clearest advantages is the lower Verbosity of Kotlin when compared to Java. When Uber was testing migration to Kotlin, they found that Kotlin led to 40% fewer lines when compared to Java [2] (it’s worth noting that Uber cared about functional equivalency over implementations being identical). The lower number of lines has many advantages for software engineering. Fewer lines of code lead to fewer errors. It also means easier debugging and testing, as it is much easier to read through the code. As Uber engineers noted, “the Kotlin compiler generates a number of synthetic elements that would otherwise need to be manually included in the equivalent Java source code”

For example, data classes can be created in Kotlin using much fewer lines than in Java. In Java, we frequently need to create a class that's main purpose is to just store data. Kotlin separates those classes into special classes by using the "data" keyword. In Kotlin, the code needed to create a data class can be written much more concisely because of this keyword. The compiler automatically derives the equals()/hashCode() pair, the toString() of the form, and the copy() function from all properties declared in the primary constructor.

Kotlin’s low verbosity by itself would be a massive advantage, but Kotlin packs that with other notable advantages. Another huge advantage is that Kotlin code is much safer than Java. Android apps that contain Kotlin code are 20% less likely to crash [1]. Kotlin achieves this by preventing developers from making common mistakes that they could make in other languages. This includes the infamous Null References, also called the Billion-Dollar Mistake [12]. “In Kotlin, the type system distinguishes between references that can hold null (nullable references) and those that cannot (non-null references)” [11]. By helping developers avoid common (and costly) mistakes, Kotlin allows developers to be more productive and spend less time on debugging/making their applications more robust.

Most big applications need integrated threading and concurrency. Kotlin is also amazing at this. Kotlin’s coroutines are well-regarded in the industry. “Kotlin coroutines make asynchronous code as easy to work with as blocking code. Coroutines dramatically simplify background task management for everything from network calls to accessing local data.” [1] Coroutines are a feature in Kotlin that allows code to run concurrently, similar to threads in Java. In Java, managing multiple threads is difficult for most programmers and usually leads to more errors in the code. Kotlin’s solution to this is coroutines, which greatly simplifies that task. Coroutines run concurrently with the rest of the code but unlike Java, they are not bound to a single specific thread. This means that behind the scenes, the coroutines will have underlying threads move and be used in other coroutines so that the threads are not blocked by waits or delays. This greatly lessens the amount of thread management needed for running concurrent code and reduces errors as a result [19].
Lastly, Kotlin also has a notable compilation time speed advantage over Java. Referring back to Uber’s experiments with migrating to Kotlin, we see that pure Kotlin code has quicker compile times than pure Java [2].
Kotlin dominates the speed advantages when compared to pure Java. Mixed Java and Kotlin seem to give the best results, however. [2]
Add to this Kotlin’s interoperability with Java (which makes mixing code possible), and we get a language that is flexible, easy to use, and powerful.
over 70% of Google's apps are built using Kotlin. This includes apps like Maps, Home, Play, Drive, and Messages. One example of success comes from the Google Home team, where migrating new feature development to Kotlin resulted in a 33% reduction in codebase size and a 30% reduction in the number of NPE crashes. [1]
What’s Next
Having already established itself in the Android market, Kotlin is now being expanded as a general-purpose language. Today JetBrains sees Kotlin as a multipurpose multiplatform programming language. As the documentation states, Kotlin can be used for Android and iOS app development, full-stack web development, and multiplatform libraries. What this means is that the core business logic can be shared across Android, iOS, and web apps using Kotlin. A developer can even use Kotlin for front end because Kotlin now has support for JavaScript and React!
Once again, the interoperability with Java and other platforms is a game changer. Developers can migrate code incrementally, instead of having to redo entire batches at once. Kotlin has a bright future, with a lot of potential for future expansion. Thanks to the amazing language features and support from giants like JetBrains and Google, Kotlin is poised to become a huge player in the developer ecosystem.
Loved the post? Hate it? Want to talk to me about your crypto portfolio? Get my predictions on the UCL or MMA PPVs? Want an in-depth analysis of the best chocolate milk brands? Reach out to me by replying to this email, in the comments, or using the links below.
Stay Woke.
Go kill all,
Devansh <3
Reach out to me on:
Instagram: https://www.instagram.com/iseethings404/
Message me on Twitter: https://twitter.com/Machine01776819
My LinkedIn: https://www.linkedin.com/in/devansh-devansh-516004168/
My content:
Read my articles: https://rb.gy/zn1aiu
My YouTube: https://rb.gy/88iwdd
Works Cited
“Android’s Kotlin-first Approach.” Android Developers, developer.android.com/kotlin/first. Accessed 7 Oct. 2022.
Fernandes, Edgar, et al. “Measuring Kotlin Build Performance at Uber.” Uber Blog, 30 Apr. 2019, www.uber.com/en-NL/blog/measuring-kotlin-build-performance.
Google Developers. “Developer Keynote (Google I/O ’17).” YouTube, 18 May 2017, www.youtube.com/watch?v=EtQ8Le8-zyo&feature=youtu.be.
Google. “Celebrating 5 Years of Kotlin on Android.” Android Developers Blog, 17 Aug. 2022, android-developers.googleblog.com/2022/08/celebrating-5-years-of-kotlin-on-android.html.
Google. “Android’s Commitment to Kotlin.” Android Developers Blog, 6 Dec. 2019, android-developers.googleblog.com/2019/12/androids-commitment-to-kotlin.html.
Android Developers. “5 Years of Kotlin on Android #Hi5KotlinOnAndroid.” YouTube, 16 Aug. 2022, www.youtube.com/watch?v=9C3-HcP5xBI&feature=youtu.be.
“Stack Overflow Developer Survey 2019.” Stack Overflow, insights.stackoverflow.com/survey/2019. Accessed 7 Oct. 2022.
“Stack Overflow Developer Survey 2020.” Stack Overflow, insights.stackoverflow.com/survey/2020. Accessed 7 Oct. 2022.
“Stack Overflow Developer Survey 2021.” Stack Overflow, insights.stackoverflow.com/survey/2021. Accessed 7 Oct. 2022.
“Stack Overflow Developer Survey 2022.” Stack Overflow, survey.stackoverflow.co/2022. Accessed 7 Oct. 2022.
“Null Safety | Kotlin.” Kotlin Help, kotlinlang.org/docs/null-safety.html. Accessed 7 Oct. 2022.
Wikipedia contributors. “Tony Hoare.” Wikipedia, 4 Sept. 2022, en.wikipedia.org/wiki/Tony_Hoare.
Krill, Paul. “JetBrains Readies JVM-based Language.” InfoWorld, 23 July 2011, www.infoworld.com/article/2622405/jetbrains-readies-jvm-based-language.html.
“JVM Languages Report: Extended Interview With Kotlin Creator Andrey Breslav.” JRebel by Perforce, 22 Apr. 2013, www.jrebel.com/blog/interview-with-kotlin-creator-andrey-breslav.
Jeremov, Dmitry. “Why JetBrains needs Kotlin.” The JetBrains Blog, 2 Aug. 2011, blog.jetbrains.com/kotlin/2011/08/why-jetbrains-needs-kotlin.
Costello, Katie. “Gartner Says Worldwide Sales of Smartphones Returned to Growth in First Quarter of 2018.” Gartner, 29 May. 2018, web.archive.org/web/20180829072934/https://www.gartner.com/newsroom/id/3876865. Accessed 7 Oct. 2022.
Niccolai, James. “Oracle Wants $9.3B for Google’s Use of Java in Android.” Computerworld, 28 Mar. 2016, www.computerworld.com/article/3048774/oracle-wants-93b-for-googles-use-of-java-in-android.html.
GeeksforGeeks. “Difference Between Java and Kotlin in Android With Examples.” GeeksforGeeks, 27 May 2020, www.geeksforgeeks.org/difference-between-java-and-kotlin-in-android-with-examples.
“Coroutines Basics.” Kotlin, 20 Oct. 2022, kotlinlang.org/docs/coroutines-basics.html.
Gill, Navdeep Singh. “Kotlin Vs Java: Which Is Better for Android App Development?” XenonStack, 6 Sept. 2022, www.xenonstack.com/blog/kotlin-andriod.