Why Google Adopted Kotlin for Android

/, Kotlin/Why Google Adopted Kotlin for Android

Why Google Adopted Kotlin for Android

By | 2018-05-07T13:52:28+00:00 April 25th, 2018|Android development, Kotlin|11 Comments

Google announced official support for Kotlin programming language for Android development almost a year ago. Happy anniversary. This is a perfect opportunity to discuss why Google decided to adopt Kotlin in the first place.

The first post I wrote on this topic was Kotlin vs Java the Whole Story. In this article I attempted to assess the effect of Kotlin adoption instead of Java in software projects. To achieve this goal I used several quantitative estimation techniques because I don’t trust subjective opinions (not even mine).

The result of the estimations showed that even if Kotlin is much “better” language than Java, its adoption on projects staffed with experienced Java developers is likely to be counter productive. It will most probably increase the total effort required for completion of such projects.

Such a surprising conclusion naturally led to a question “why Google adopted Kotlin for Android then?” and I promised to address it shortly.

However, following the surprising amount of feedback for that post, I decided that it is worth discussing Why JetBrains Invented and Promotes Kotlin first. So, in that post I described what I believe to be the actual motivation behind JetBrains huge investment into development and support of Kotlin.

So, now I would like to address the question that bothered me for an entire year – why Google adopted Kotlin for Android?

Disclaimers:

I feel obliged to state a decent amount of disclaimers and warnings.

First of all, effectively everything I write in respect to Google’s adoption of Kotlin is highly speculative. These are my personal thoughts and opinions. I don’t have any kind of insider information from either Google or JetBrains. The only information I had access to during my research had been already publicly available on the internet.

Also, analysis of business motivation behind strategic decisions of multi-billion corporations is not exactly my area of expertise. I currently make a living as an independent Android developer, software consultant and online educator. My professional experience is largely irrelevant to the topic at hand.

Therefore, take absolutely everything I say in this context with a grain of salt. You can basically treat this entire write-up as a work of fiction that could only take place in a parallel universe. Please don’t make any decisions based on the contents of this post.

How much Kotlin cost Google:

Have you ever thought how much Google paid to introduce Kotlin into Android?

This question usually surprises the developers I talk to about this topic. The answer in most cases is that Google got Kotlin for free because it is released under Apache 2.0 open-source license.

For us software developers, this line of thought is very natural due to our romantic view of open-source projects. However, the reality is quite different and its governed by practical economical considerations.

Research and development costs:

First of all, Kotlin adoption required a considerable amount of R&D effort.

Adjusting the tools and the entire Android framework to Kotlin probably consumed tens of thousands of man-hours in effort so far. Software developers, project managers, product managers, team leaders and middle managers – many or event most of Google’s employees involved in development of Android framework and the associated tools put in some amount of effort for Kotlin.

Assuming that Google spends a conservative $100 per man-hour on average, the technical costs alone are in the many millions of dollars.

Edit:

Following the initial feedback I feel that I did a disservice to my readers by assuming that this point is almost trivially clear. Let me show you how I arrived to these numbers and convince you that they are very conservative.

First of all, I estimated how many Google employees involved in Android R&D. All employees, not just software developers. In my opinion, there should be at least 1000 of them. I wanted to be careful so I took a factor of 10x to be on the safe side and assumed 100 employees.

By multiplying the above number by 2000 work hours in a year I arrived at 200,000 work hours in total. This is the amount of work hours that Google employees who’s work is related to Android R&D worked in the last year alone.

It means that if these employees spend 5% of their time on average on Kotlin related work, Google paid for 10,000 man-hours of effort related to Kotlin since the official announcement.

In practice, I think that there are much more Google employees involved in Android R&D. In addition, Google started investing in Kotlin long before the official announcement to make sure that it will actually work.

Therefore, I feel very confident stating that Google employees spent tens of thousands of man-hours of R&D effort on Kotlin so far.

Estimate of average salary at Google can be easily found on the internet. Most sources agree that it is around $200,000 a year (incl. all benefits). That’s about $100 a hour. Please note that this is just the salary average. The total cost of an employee for Google is inevitably higher.

As you can see by yourself, even the most conservative estimation shows that Google indeed spent millions of dollars on Kotlin so far.

Public relations costs:

Then there are PR costs.

I don’t remember any another PR company aimed at Android developers comparable to what Google does with Kotlin. It’s being promoted the way no other tool for Android have ever been promoted in my memory.

Such an intense PR push is especially puzzling given that Kotlin is not even Google’s product.

I would estimate PR costs to also be in the millions.

Legal costs:

Many people think that since Kotlin is released under Apache 2.0 license, Google can just use it without any additional arrangements with JetBrains. After all, that’s exactly what Apache 2.0 license states.

Well, technically it is true that anyone can use Kotlin for free. However, in practice, Apache 2.0 license is a double-edged sword.

Consider the following sections of Apache 2.0 Terms and Conditions:

7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
Apache 2.0 Terms and Conditions

The above disclaimers state that if Kotlin would be adopted according to Apache 2.0 license alone, JetBrains would have absolutely zero obligations and responsibilities towards Google. Let me list several examples of what JetBrains could do in that case:

  • Not provide support for Android.
  • Give low priority to bugs that affect Android ecosystem.
  • Change Kotlin licensing model and disallow Google to use future Kotlin versions.
  • Discontinue Kotlin project altogether and not transfer ownership to anyone.
  • Many more actions that could undermine the stability of the entire Android development ecosystem.

However improbable the above scenarios might seem, Google would not risk adopting Kotlin if it had zero control over it. But how could Google get any kind of guarantees and control over a product released under Apache 2.0 license?

Well, the above quotation from Apache 2.0 Terms and Conditions clearly states how: “agreed to in writing”. In other words – signed contracts.

I’m sure that these contracts are a very interesting read. At the very least, Google probably wanted to ensure that JetBrains will be fully committed to Kotlin in Android. JetBrains from their side probably wanted to ensure that Google wouldn’t be able to hijack Kotlin ecosystem or attempt to release a competing IDE.

The above points are just several reasonable guesses of mine. The actual contracts probably include many more terms and conditions which describe the obligations of the parties in great details. Non-competes, service level agreements, IP ownership, trademarks, copyright, etc. – all of these topics had to be negotiated, formulated, captured in contracts and then reviewed by many eyes.

All these activities probably required involvement of the best lawyers in the industry.

How much do these services cost?

I don’t know enough about this subject to even get a ballpark figure. I believe that legal costs for Google alone were in millions as well.

Opportunity costs:

Finally, there is an opportunity cost associated with the effort Google employees put into Kotlin adoption. And they will continue to put additional effort into supporting Kotlin for years to come. We are probably talking about hundreds of thousands of man-hours in total.

All this effort will be spent by what many consider to be the most talented group of people on the planet.

I get overwhelmed when I try to imagine what Google could achieve by directing this effort towards actually improving existing products or exploring new opportunities.

Kotlin adoption is a risk to Google:

In addition to costs discussed in the previous section, Google also took a long term risk by adopting Kotlin.

Java is not going to disappear from Android any time soon. Therefore Google will need to support Android projects that use both Kotlin and Java for quite some time. Currently, this requires different sets of tools to be used.

As a result, Android platform will be affected by issues from two different toolchains, plus the issues related to the integration between them.

This is a very unfortunate prospect for Google. The Android developers community will blame them for all the issues associated with Kotlin adoption, which is only fair. This is a serious risk to Google’s reputation.

Why Google adopted Kotlin for Android:

When I heard that Google officially adopted Kotlin I was totally puzzled. I immediately realized that Google will pay a lot for this endeavor and take on high risks. I couldn’t see a way for them to get a return on this investment.

So I started to analyze this situation from various angles. This analysis quickly culminated into some really troubling conclusions.

I’m going to lead you through that same analysis.

Kotlin is a better language:

I discussed this topic in great details in my post Kotlin vs Java the Whole Story, so I won’t repeat myself here.

Let’s assume that Kotlin is indeed the best programming language ever and it speeds up Android projects by 10%. Not just the software construction part of the projects, but the entire projects. This is a ridiculous assumption, but forget about that for a moment.

Now imagine the following conversation taking place between middle level manager (MLM) and an executive (E) at Google:

MLM: “We want to adopt Kotlin. This will speed up all Android project by 10%!”

E: “Sounds great! I will check it with analysts, lawyers, accountants, human resources and strategic committee and get back to you.”

… after some time ….

E: “The estimated cost of Kotlin adoption is in tens of millions of dollars. It will take months to just negotiate the licensing terms. We will also need to accept additional long term liabilities and risks. Finally, there is no correlation between the speed of execution of Android projects and Google’s revenues, so ROI will be zero. The answer is NO!”.

And I haven’t even mentioned Oracle vs Google lawsuit.

I will discuss this lawsuit later in detail. Now just imagine that you’re an executive at Google. Your company is involved in a years long lawsuit. You’ve already spent tens or even hundreds of millions of dollars on lawyers, and are still at risk of losing billions in the future.

So, you’re troubled by the mere thought about Android and programming languages. And here comes someone who suggests you adopt a new programming language in Android for the sake of 10% faster application development.

New PROGRAMMING LANGUAGE in ANDROID! Really?

I’m pretty sure that this conversation never actually took place because Google is known to employ only smart people. Nevertheless, it correctly reflects the absurdity of the idea that Google adopted Kotlin because it is somehow better than Java.

Google adopted Kotlin in response to community request:

Google representative said the following when announcing official Kotlin support in Android at Google IO 2017:

[…] Kotlin is what our developer community has already asked for […]Google representative; Google IO 2017

There are two premises in this seemingly simple statement:

  1. Android developers community asked for Kotlin.
  2. Google acted on community’s request.

Let’s review each of these two premises separately.

Android community did not ask for Kotlin:

Android developers community has never asked for Kotlin officially.

There are 168 tickets with the word “Kotlin” in Google issue tracker that were created before Google IO 2017. I went over all of them and didn’t find any feature request for official Kotlin support.

I will show you how such a request actually looks like in a minute.

Prior to the official announcement only a negligible minority of Android developers worked with Kotlin and promoted it. Yes, some of them were very prominent community members. But still, they don’t speak on behalf of millions of Android developers.

Even today, a year after the official adoption, most Android developers don’t use Kotlin professionally, in my observation. One could say that they are still enthusiastic about Kotlin and eagerly learn it nonetheless, but it is not an enthusiasm that drives the adoption of Kotlin.

In my opinion, Kotlin adoption is being driven by fear.

If you listen carefully to Android developers, you will hear that not all of them are enthusiastic about Kotlin. Many developers who seem eager to use Kotlin are just afraid of falling behind professionally. They fear that their future employment prospects are at risk without it.

I can’t say whether they right or wrong.

Google did not share any long term plans with the community regarding the future of Java in Android. Currently it is supported, but for how long nobody knows? Two years? Five years? Forever?

It’s this lack of information, combined with Google’s excessive PR efforts for Kotlin, that create a sense of urgency and fear among Android developers. This fear is then being re-framed as enthusiasm to create the illusion of happy adoption.

So as you can see, the Android community did not ask for Kotlin, and what’s being marketed as enthusiasm might very well be simple fear. Fear for professional future caused by Google’s unwillingness to share essential information with the community.

Google doesn’t act on community requests:

Now let’s see how a real request by Android community looks like and how Google treats such requests.

Arguably, the most basic attributes of any text element in GUI system are color, size and font (content aside). Android supported all of them from day AFAIK. With just one “small” caveat – it was impossible to set custom fonts to fields from XML files.

Developers who were around back then probably remember how many hacks had been employed to address these limitations. Eventually, active community members captured the best of these hacks into open-source libraries.

On Nov 16 2010, a new feature request was added in Google’s issue tracker asking for the ability to reference custom fonts in XML. You would think that such a basic functionality would be implemented very quickly. Especially given how much hacky code developers had to write to work around these limitations back then.

On Dec 8 2014, more than 4 years later, this feature request was closed as “obsolete”. Needless to say, it wasn’t obsolete by any means.

Not surprisingly, a community member who noticed that the old issue was closed for no apparent reason opened a new one on Dec 25 2014.

If you click on that link and read some of the comments you will immediately understand how a true request from the community looks like. I also find this entire thread funny. I tried to star this ticket myself, but had to unstar it shortly afterward. Like many other community members, I didn’t like being bombarded with new comments notifications.

The ability to specify custom text fonts in XML was finally added only on Mar 21 2017, about 2 years later. In total it took more than 6 years until the community received this basic feature from Google.

Needless to say that this feature was nowhere as complicated and expensive to implement as support for Kotlin. In my experience, this feature is representative of Google’s handling of real feature requests from the Android community.

As you can see, there wasn’t a real request for Kotlin from the community. Google doesn’t care too much about community requests anyway.

In addition, “the community asked for it” as a reason wouldn’t stand a chance in the aforementioned imaginary conversation between middle level manager and executive at Google.

Oracle vs Google lawsuit over Java:

Let me jump forward and say that I believe that Oracle vs Google lawsuit is the real and the only reason for Kotlin adoption in Android.

Surprisingly, most Android developers seem to accept the idea that there is a connection between the lawsuit and Kotlin adoption.

What about you? Do you personally believe that Kotlin in Android has anything to do with Oracle vs Google lawsuit? Think about this question for a moment.

Some Kotlin proponents say that Google adopted Kotlin in Android because of the lawsuit AND because Kotlin is better than Java. Unfortunately, this statement simply can’t be correct. Let me explain why.

Suppose that Kotlin adoption is indeed related to the lawsuit. Who would need to approve this project? In other words, what’s the title of Google employee who can approve a decision that has the potential to affect the outcome of multi-billion dollar strategic lawsuit?

In my opinion, that would be the CEO. It is even probable that CEO wouldn’t be able to decide on this topic all by himself and would seek the approval of board of directors.

So, imagine the highest level executives and/or board members discussing this idea. They need to make a strategic decision that costs tens or even hundreds of millions of dollars and has the potential to affect this monstrous multi-billion lawsuit.

Now, let’s assume that Kotlin is known to be 10% worse than Java in all aspects. Do you really think that this fact could affect the final decision in any way?

I don’t think so.

I’m not saying that this question couldn’t be asked. At the end of a day, some Google top executives and board members were techies in the past. What I’m saying is that even if Kotlin would be shown to be worse than Java, this would have no effect on the decision about its adoption.

Therefore, if Kotlin adoption is related to Oracle vs Google lawsuit, it can’t be related to Kotlin’s qualities in any way. Several levels of corporate hierarchy separate between people who would discuss programming language qualities and top executives who decide on behalf of multi-billion corporation.

So, back to the fact that I personally think that Kotlin adoption is related to Oracle vs Google lawsuit. I think it is true because I just don’t see any other reasonable explanation. I already showed you how alternative explanations disintegrate once you start analyzing them rationally.

Oracle vs Google lawsuit is the only visible reason that is important enough to justify such a huge investment on Google’s side.

Does Kotlin really help Google in the lawsuit against Oracle:

I knew very little about Oracle vs Google lawsuit a year ago. In a nutshell, I thought that Oracle sued Google over usage of Java programming language.

In my imagination Oracle was a greedy bully who attempted to get into Google’s pockets at all costs. I thought that Oracle was so evil that it was ready to destroy open-source software to achieve its goals. Google in my imagination was a nice guy who stood up to the bully to restore justice and protect all free software.

With all this in mind, adoption of Kotlin seemed like a reasonable act of defense from Oracle’s greed. However, I quickly realized that my view of the situation had been quite naive after I started my research of this topic.

As many of you probably already know, the lawsuit is not related to Java programming language. It is about Java APIs.

But the realization that Java APIs are at the heart of the dispute poked a huge hole in my arguments because Kotlin uses them under the hood as well. Therefore, adoption of Kotlin didn’t change the legal situation for Google at all.

So, I made a mistake. I evidently missed something important which is unrelated to the lawsuit. Something that could explain why Google is so invested in Kotlin on Android.

I tried to account for additional factors like the fact that Google pays JetBrains for IntelliJ IDEA. I tried to speculate about long term platform evolution goals like the possibility of changing the distribution channel for Android apps to instant apps or even web exclusively.

However, none of these factors, or even a combination of several factors, seemed as a reasonable explanation.

After a while I realized that I made a full cycle and got back to where I started. Oracle vs Google lawsuit was the only visible factor that could potentially explain adoption of Kotlin for Android.

Since I still couldn’t understand how exactly Kotlin could be beneficial to Google in this context, I concluded that there is something about the lawsuit itself that I missed. So I decided to dig into the legal details of this huge lawsuit.

Long story short, I think I found the explanation for Kotlin in Android. This is good news.

The bad news is that I’m worried about something else now. It is even more troubling than Google adopting Kotlin and being dishonest with Android community.

However, I can’t tell you what it is right now. You’ll need to understand the main aspects of Oracle vs Google lawsuit to see the situation the way I see it. This is a big topic alone that justifies an entire article all by itself.

Edit:

It looks like I confused many readers with this statement. Let me clarify myself please.

I already told you that I think that Google adopted Kotlin for Android in response to Oracle vs Google lawsuit. This adoption has nothing to do with Kotlin being potentially better than Java or imaginary community request. The goal of this entire post was to show you that this is the only valid reason for such a move.

That’s the answer to the question in the title.

What I can’t share with you right now are my thoughts about what might be the implications of Google initiating this major shift in its own interests. You need to understand what the aforementioned lawsuit is actually all about to see the situation as I see it.

Conclusion:

Time to wrap up this post.

Until now I described why I was bothered by official support for Kotlin in Android in the first place. Google invested lots of resources and took serious risks, yet it was not clear to me why they did that.

I showed you how I ruled out all potential explanations for Kotlin adoption except for one. Oracle vs Google lawsuit is the only visible factor that is important enough to justify such an investment from Google.

I know that this article feels incomplete.

Unfortunately, it was practically impossible to fit all the things I wanted to say in a single post. In my estimation, it will take at least two more articles before you get the whole picture.

In the next post I will summarize for you the main aspects of Google vs Oracle lawsuit. After that I will write the last article in which I will share my troubling thoughts about Android and Kotlin (and some more stuff).

At this point I would like to remind you that absolutely everything you read so far are my speculations. They are based on publicly available information only. Treat all the information in this article as a mental exercise that I decided to share with you. Again, please don’t make any important decisions based on the contents of this post.

As always, leave your comments and questions below and consider subscribing to our newsletter if you liked this article.

11 Comments

  1. Vladimir Grabarchuk April 25, 2018 at 8:05 pm - Reply

    Hello Vasiliy,

    Another interesting read – thank you for the time and effort taken to produce it.
    Beyond that, all I can say is… you know how to keep your readers in suspense:)

    Looking forward to the continuation!

    • Vasiliy April 25, 2018 at 8:37 pm - Reply

      Hi Vladimir,
      I’m glad you found this article interesting because I indeed put a considerable effort in it.
      Will try to write and publish the next parts ASAP.

  2. Phileo99 April 25, 2018 at 11:36 pm - Reply

    Hi Vasiliy,

    Glad to read that you’ve addressed the Elephant in the Room that no one wants to directly talk about – and that is Android Developers adopting Kotlin out of fear. I would like to characterize it as this:

    Initially, there was a certain percentage of pro-Kotlin Android developers who were actively evangelizing Kotlin. Then there was a smaller percentage of neutral Android developers who were successfully persuaded by the pro-Kotlin developers. Things slowly built to a tipping point when Google announced their official support for Kotlin at Google I/O last year.
    That event alone increased the momentum of Kotlin adoption. If Google did announce any long term plans for Java support on Android, it was certainly drowned out by the pro-Kotlin news, activity and PR.
    So then you now have the remaining percentage of neutral Android developers who fear being left behind because they have not yet adopted Kotlin.
    That fear only feeds into more Kotlin adoption.

    • Vasiliy April 26, 2018 at 10:39 am - Reply

      Hey, thanks for sharing your opinion.

      I find your description to be quite accurate and insightful.

      In your opinion, what fraction of Android developers fall into the category of developers who adopt Kotlin out of “professional fear”? I’m curious whether our observations are consistent.

  3. Andrei Mishchenko April 26, 2018 at 1:52 am - Reply

    > I believe that Oracle vs Google lawsuit is the real and the only reason for Kotlin adoption in Android.
    I believe you don’t understnad reason of Oracle vs Google lawsuit, Kotlin or any other language forr application development just not a part of this lawsuit and cannot some how help.
    Maybe make sense to check this topic before publish articles about this.

  4. Adam April 26, 2018 at 2:13 pm - Reply

    Such a long article concluded that you are not going to tell why!

  5. MJ April 26, 2018 at 9:59 pm - Reply

    I feel like you wrote the positive comments yourself. Anyway, I read your conspiracy theories for the same reason I watch B-rated movies. Keep doing what you’re doing.

    • Vasiliy April 27, 2018 at 5:21 am - Reply

      Hey,
      Took me a second to understand what you mean.
      Let’s get even more conspirative – I write all comments myself. So, now I’m replying to myself and you might not even exist… 😉
      Why do you watch B-rated movies by the way?

  6. Febin Kattekkadan May 5, 2018 at 11:13 am - Reply

    If​ you arrange Kotlin – Flutter – Fuchsia in that order and keep the Big Oracle suit in the background, you might see a still bigger picture. But I won’t say what it is 😉

    • Vasiliy May 5, 2018 at 12:35 pm - Reply

      Hi Febin,
      Yeah, don’t say please – you’ll spoiler my upcoming post 😉
      Come back in several days or subscribe for post notifications and let’s compare our intuition after I write the last post in this series.

  7. Syed Ekram Uddin Emon August 13, 2018 at 9:26 am - Reply

    Your mental exercise worth reading, thanks to your brain.

Leave A Comment

Stay Connected!

Receive notifications about new posts and resources straight into your inbox!
SUBSCRIBE
close-link