Thomson Reuters
- Kotlin has become the fastest-growing programming language according to GitHub, and it's increasingly being used by companies like Google, Square, Pinterest, Pivotal, Capital One, and Atlassian.
- Kotlin was originally developed by software tool company JetBrains in 2010 as an alternative to Java, and it takes away some of the "pain points" of Java like null pointer exceptions, which frequently cause Java apps to crash.
- Business Insider spoke with various companies on how they decided to use Kotlin and why it's so loved by Android developers.
- Visit Business Insider's homepage for more stories.
When Square software engineer Valeriy Ovechkin started on the team for Square's restaurant app Caviar, the app was completely written in Java.
Java is one of the most widely used programming languages in the world, originally created by the Oracle-acquired company Sun Microsystems. It's commonly used to write databases and Android apps.
But Java, which dates back to 1995, can be a bit clunky, developers say. Increasingly, Android engineers are using the newer open source programming language Kotlin to write their apps instead. As for Caviar, it's now 100% in Kotlin.
"Kotlin in itself is a modern programming language," Ovechkin told Business Insider. "I've seen other features in Kotlin that make development more delightful. Kotlin is easier to pick up and more expressive. Writing the same code in Kotlin usually results in fewer lines of code."
Kotlin has quickly skyrocketed in popularity. It's used by companies like Google, Square, Pinterest, Pivotal, and Atlassian. It's the #1 fastest growing language according to GitHub, the "Facebook for programmers," growing over two and a half times in the past year. It was voted one of the top five most loved languages according to Stack Overflow, a site for developers to ask and answer questions about code. There are even meetups specifically focused on Kotlin.
Business Insider
"What is interesting with Kotlin is basically it leverages the existing skills of Java developers and finds the right tradeoffs to provide new features and provide things that make Java developers more efficient without going too far," Pivotal engineer Sébastien Deleuze told Business Insider.
A "passion project"
Kotlin was originally created in 2010 by the software tool company JetBrains to fix Java's "pain points."
"Back when we started Kotlin, Java was generally a very verbose language," Hadi Hariri, vice president of developer advocacy at JetBrains, told Business Insider. "There's a lot of things you have to do to get code to work...We embraced the good and got rid of some of the pain points. This kind of leads to Kotlin being the language people started to fall in love with."
The language really exploded after May 2017, when Google gave Kotlin a stamp of approval when the Android team announced first class support for Kotlin.
Getty
That's what got Atlassian's mobile development team using Kotlin. Initially, there was hesitation about using Kotlin for Atlassian's products, says Jerry Cheng, head of mobile development at Atlassian. Without Android's full support, the team thought it was risky to invest in Kotlin.
But once Google announced it would officially support Kotlin for Android, this was a greenlight for the team to jump on board. Now, Atlassian uses Kotlin for its Android apps of its various products, like Trello, Jira, and Confluence.
"We were fortunate in that Atlassian was relatively new to mobile," Cheng told Business Insider. "We embraced Kotlin pretty quickly and extensively. There were a lot of advantages. It's more condensed. It really helps with consumption and maintenance. Since our adoption, everything has been great."
Likewise, Square's Ovechkin decided to rewrite the Caviar app to Kotlin as a "passion project." He proposed the idea to the team, saying it would allow Square to develop even faster.
And in September 2017, he made his first Kotlin conversion in Caviar. From then on, he would write new features in Kotlin, and he gradually started converting the rest of the app to Kotlin as well.
"A neat thing about all this is we undertook the conversion with no noticeable impact to customers," Michael White, Caviar engineering lead at Square, told Business Insider.
Avoiding the "billion-dollar mistake"
With Kotlin, the code is more concise, making the code base smaller and easier to manage. Instead of getting stuck on syntax, engineers can focus on more complex, larger-scale problems. Ovechkin estimates that the code base is now smaller by 15-25%.
With Java, software developers commonly ran into a bug called a "null pointer exception." In Java, variables can be "null" as a default, meaning it does not have any value attached to it. A "null pointer exception" is when the code references a variable, but the variable has no value when the application is running.
As a result, the application doesn't have any option except to crash. The computer scientist who invented null references, Tony Hoare, once called this his "billion-dollar mistake."
However, Kotlin makes sure developers won't run into that problem. It assumes variables can't be "null" unless a developer explicitly make it that way. This makes Kotlin apps more stable and less likely to crash.
Although converting the app to Kotlin took significant amounts of work, Square's Ovechkin says it's worth the investment.
"If you believe in the outcome, it's not risky for this proposal," Ovechkin said. "It's an investment you have to make and a learning curve."
Mix and match
Another benefit is Kotlin's compatibility with Java, the original language that Android apps are usually written in. Essentially, developers can mix and match both languages. Since Kotlin is completely compatible with Java, developers can incrementally convert their apps.
Atlassian
While Square completely rewrote its Caviar app in Kotlin, Atlassian kept its apps in Java, since it's compatible with Kotlin. However, for new features, developers use Kotlin. Cheng says the Atlassian team doesn't see value in spending time completely rewriting apps just to rewrite them, but he does see Java slowly being phased out.
"The way I would position ourselves is we're straight up doing Kotlin, but we don't find a need to rewrite everything just to achieve parity," Cheng said. "If we update features, we usually try to rewrite them if time allows and the value is there."
Like Atlassian, Capital One doesn't have plans to completely convert the app to Kotlin, as both languages work "nicely together," says Keith Forsythe, vice president of engineering at Capital One. Currently, Forsythe says, about half of the Android engineers at the company use Kotlin, and the other half uses Java the Capital One mobile banking app.
"We're pretty passionate about the developer experience," Forsythe told Business Insider. "We try to look for any new technology that can help us and give us any sort of advantage."
Never going back
At Square, Kotlin doesn't only help with writing apps - it can help with recruitment. White, the Caviar engineering lead, says that Square wants to be on the leading edge of using Kotlin, and he says the fact that Square is a leader can be a "differentiator" for Square when hiring talent.
Atlassian's Cheng also says it lowers the barrier to the software industry. Kotlin is a language that's more modern and easier to use, and it could increase the number of people who learn to code.
"Modernizing the programming language and taking care of the challenges of computer programming will improve the supply side of how many people can learn how to write programs and software," Cheng said.
Would developers return to using the tried-and-true legacy language Java? Ovechkin, the Square engineer, says it would be "definitely painful." Both he and White do not see much benefit in going back to it at Square, and they expect to see less and less Java over time.
"There's a sense of fulfillment and satisfaction you get when the tools click into place and solve the problems over and over again," White said. "You feel that over and over again and it builds a momentum of passion. A lot of engineers are feeling that with Kotlin."
Get the latest Google stock price here.