What Kotlin is all about — As explained by Hadi Hariri
JetBrains announced in late January that Kotlin 1.1 has reached beta. We invited Hadi Hariri, VP of Developer Advocacy at JetBrains, to talk about Kotlin’s strengths and the upcoming 1.1 and to answer the question that’s on everyone’s lips: What does the future hold for Kotlin?
JAXenter: JetBrains is first and foremost known for IntelliJ IDEA. And now there is Kotlin. How does it fit into this picture?
Hadi Hariri: That’s partially the case. I believe in the Java community, IntelliJ IDEA is our best-known product, but we’ve had success with ReSharper in .Net as so other products on other stacks. Kotlin, a language, is still a tool and what we’ve created is a tool, like our other ones, that focuses on efficiency and dealing with the clutter of software development.
JAXenter: What was your motivation for inventing Kotlin?
Hadi Hariri: The first reason for Kotlin was for us to use it in our products. We wanted to cut down our codebase, introduce some new constructs and after looking at our options, we saw that creating our own was a viable option
JAXenter: What does Kotlin have to offer that other languages fail to provide?
Hadi Hariri: I don’t think Kotlin offers anything specific in terms of features that are unique, with the exception of maybe a few things. In fact, Kotlin is inspired by many other languages and when developing we looked at both the good and should we see not so good, or pain points of other languages. What we did was try and solve some of these pain points. The entire picture put together is what provides an interesting option.
Kotlin is inspired by many other languages.
JAXenter: Can you describe the core principles of the language?
Hadi Hariri: Readability, conciseness, safety and being able to tool the language are some of the main characteristics. As well, of course, as the important interoperability with Java.
To give you an example, a typical Java Bean which has a series of properties with getters, setters, equals, toString, etc. In Kotlin could just be:
data class Customer(var name: String, var email: String)
That line alone gives you all the same functionality as you’d have in 30 lines or so of Java code. Or let’s say casting. A lot of times I want to cast something to a different type in order to invoke a method on it, once I’ve verified that it’s of that type:
if (person is Employee) person.vacationDays = 30 }
In Java, you’d need to explicitly cast person to Employee after the compiler checks it. In Kotlin it’s no longer required. It’s just the things that add up to make it much smoother.
JAXenter: One of the advantages of Kotlin is the interoperability with Java. How can you convince a Java developer to try Kotlin? What argument would you choose?
Hadi Hariri: Personally, I’d use the same argument that I use when people ask me if they should try IntelliJ IDEA as opposed to their current IDE. There is no unique feature that will convince them. It’s about the experience and approach we take when designing the product. We don’t believe we should be selling features but ways to solve people’s problems.
With Kotlin, I believe it’s the same case. Obviously investing in a language is not the same as using one IDE or another, albeit both are tools. But here I believe the Java interoperability, readability and our conscious choice to make it similar to existing languages lowers the potential risk.
JAXenter: Of course, Kotlin can also be used on its own. Which use cases did you have in mind?
Hadi Hariri: Kotlin can be used for any type of application because that was our goal, to create an industry language that can be used to develop a desktop, server, web or mobile application.
We don’t believe we should be selling features but ways to solve people’s problems.
JAXenter: Kotlin invokes its coherent syntax and its fast compilation. How do you intend to keep that status as Koltin grows?
Hadi Hariri: That’s a question you should ask Andrey Breslav I guess, the team lead behind it. But I believe it’s about thinking carefully what you add to the language and having sufficient use-cases that would justify it. There’s always a trade-off.
JAXenter: What’s your favorite trick in Kotlin?
Hadi Hariri: I don’t necessarily have a trick, but what I like about Kotlin and use quite a bit is the terse syntax for working with higher-order functions (functions that take functions as parameters or return functions). I’ve been using this quite a bit lately, and replacing some more object oriented code with simple functions.
JAXenter: What does the future hold for Kotlin?
Hadi Hariri: We are releasing 1.1 very soon and it contains an initial support for co-routines, which we believe can significantly help developers with asynchronous programming. We’re also working on Kotlin native support and that is definitely quite exciting!
Thank you very much!