LAURENCE MORONEY: With the announcement of Kotlin,
it's an exciting time to be an Android developer.
Today on "Coffee with a Googler,"
I'm chatting with one of the people who made it happen,
Jeffrey Van Gogh.
So one of my favorite moments at Google I/O this year
was when we did that Kotlin reveal,
and it was the Android lock screen.
And they carved out the K in it, and the crowd went crazy.
And Jeffrey, I know you're one of the guys behind this.
What was it like to bring Kotlin to Android?
JEFFREY VAN GOGH: Oh, it was amazing.
I joined Android Studio two years ago.
And of course, we talked out to customers.
And we started hearing that people thought that Java
was not really moving forward.
They wanted to get more modern language features.
And so as we started looking into that,
one of the things that came up are these people really
like Kotlin.
And so about a year ago, I started playing with it.
And it's so much more productive.
It's so much fun.
I had cut a lot of the things that I really liked about C#,
but still a lot of the compatibility with existing
Java libraries.
And then they added a whole bunch of new things
on top of it as well.
And so it just makes programming a lot more fun.
And so we need to get this into our customer hands.
And so the weeks, months, leading up to I/O,
we had a lot of talks with JetBrains
to see if we could get it done.
And we got it done.
And people really are excited, and we are very excited.
Of course, it's just a start.
We need to do a lot more hard technical work
to really make it a first class language for Android.
And there's a lot more to come over the next year.
I think we can do a lot of cool things.
LAURENCE MORONEY: So why Kotlin?
JEFFREY VAN GOGH: It's a fun language.
It's really fun to program.
It's very little code you have to write, compared to Java,
you have to implement the whole class with fields, getters,
setters, hash codes, equals.
LAURENCE MORONEY: Most of my bugs are in POJOs like that.
JEFFREY VAN GOGH: Oh, yeah.
In Kotlin, it's one line of code.
And there's many more examples like that.
It's just a fun, productive language
that makes your whole programming experience so much
easier.
LAURENCE MORONEY: And can I still
be productive as an Android developer
if I'm using, like, third party libraries and open source Java
stuff?
JEFFREY VAN GOGH: Oh, absolutely.
Kotlin interrupts with Java very simply.
They both compile to Java bytecode,
which we then compile to Dalvik bytecode
for running on Android.
And so it runs the same on the OS
and on the source language side.
It has a really good interrupt between Java and Kotlin.
You can call Kotlin from Java, Java from Kotlin.
You can even have inheritance, where your Java class
is extended by Kotlin class and extended by Java class again.
It works very smoothly.
LAURENCE MORONEY: Nice.
And then from a tooling perspective in Android Studio,
do I get, like, file new Kotlin?
JEFFREY VAN GOGH: Oh, yeah.
You can, either in existing project, add a new Kotlin file,
or when you start a new project, you just
check the box and the wizard saying,
I want Kotlin enabled to already create the default
activities in Kotlin source.
And it will set all the settings in your Kotlin plugin,
create a plugin.
It's a very smooth experience.
LAURENCE MORONEY: Cool.
You know, this actually, really, reminds me
of when Swift first came out.
And there were a lot of Objective-C developers,
and then Swift came out.
But it had that level of compatibility
that, as a Swift developer, I could
consume Objective-C libraries and that kind of stuff.
And then Swift really took off.
So hopefully, Kotlin will take off,
and Android in the same way.
JEFFREY VAN GOGH: Yeah, I hope so.
I love the language.
So I'd definitely like to see it succeed.
LAURENCE MORONEY: Now, so if I'm an Android developer,
and I've been using Android Studio for a while,
and if I've got a number of third party libraries
in Java that I'm using, can I continue to use those
if I'm using Kotlin?
JEFFREY VAN GOGH: Yeah, absolutely.
So the way that Kotlin works, it compiles down
to Java bytecode, which is the same thing that the Java
compiler does.
And then we take our tools--
the dexer that takes the Java bytecode
and converts it to Dalvik bytecode.
LAURENCE MORONEY: OK.
JEFFREY VAN GOGH: And so for the Android OS, it's just the same.
It's just Dalvik bytecode.
It doesn't know any different.
And so Kotlin, actually, has a really good interrupt story
with the Java code.
And you can actually call Kotlin code from Java,
and Java code from Kotlin.
And you can have inheritance hierarchies in between.
And it just works fine.
Because in the end, it's all bytecode.
LAURENCE MORONEY: OK, cool.
So now, like I've only used Java in Android.
It's on my to-do list to learn Kotlin.
But why all the love for Kotlin?
Why this language in particular?
JEFFREY VAN GOGH: So I think if you look at the language,
it's not a particularly innovative language.
There's not a lot of new research going on.
But they didn't set out to do that.
They wanted it to be a productive language.
So they looked at a lot of other languages
that have a lot of modern features.
And they figured, how can we interrupt this with Java,
without having to break two worlds,
and make developers more productive?
I think the area that they are more innovative
is that they started from the tool side.
Most languages, they start, and they
write a standard compiler, batch compiler, which
takes source input, and run a command line,
and produce output.
JetBrains is a tool company.
And they started, like, how do we do this in the [INAUDIBLE]??
How do we make sure that refactoring works?
How do we ensure that static analysis works?
I believe that they had the frontend working before they
had the backend working.
So it's a very different mindset.
And I think the real innovation area is in the tooling.
And that's why you see that people are so productive.
The tooling works very closely with the language,
and that makes you more productive
than in other languages.
LAURENCE MORONEY: Now your role in Google
is you work on the compiler and the compilation.
JEFFREY VAN GOGH: Yes.
So I run several teams in Android CO, and one of them
is the compiler team.
So we used to have the Jack compiler, which
converts Java source code to Dalvik bytecode.
And earlier this year, we announced that we are no longer
investing in that.
And so we started investing a couple of tools.
We were doing Java 8 desugaring for people
who want to use Java 8 language features.
So if you say, Kotlin isn't my thing,
you can still use all the new Java 8 features
in Android security space.
We're also investing in the dexer.
So the dexer converts your Java bytecode to Dalvik bytecode.
And we're doing more and more optimizations there,
making sure we use smaller code.
We're also doing work to make sure
it works very optimally with Kotlin,
so that we can make sure that your debugging scenarios work
correctly, et cetera.
And then the other thing I'm working on
is I'm working together with JetBrains on the Kotlin
Language Committee to make sure that we
evolve the language correctly.
And so that mainly focuses around breaking changes
and deprecation policies.
We want to make sure that Kotlin is
a language that people can depend on for many years
to come.
And so there shouldn't be any surprises
that the features no longer work when
you want to compile your app two years forward.
LAURENCE MORONEY: Got it.
So you're part of the language committee steering Kotlin.
JEFFREY VAN GOGH: Yeah, correctly.
LAURENCE MORONEY: So we're not just
investing in Kotlin being part of our tools,
but we're really heavily invested
in the language itself.
JEFFREY VAN GOGH: Yeah.
We announced at Google I/O there is a foundation being formed.
And as part of that, there is a committee
with one person from JetBrains, one person from Google,
and an independent.
And so we are looking at the language
and making sure that we don't break people
as we are building new, cool features.
LAURENCE MORONEY: Excellent.
That sounds really cool now.
The one thing I hear about Kotlin always is that it's fun.
JEFFREY VAN GOGH: Yeah, it is.
LAURENCE MORONEY: It's fun to play with.
What makes it so much fun?
JEFFREY VAN GOGH: So for me, it's particularly fun.
I've been doing programming languages for my whole career.
I have been working on compilers and static analysis tools
for 15 years.
LAURENCE MORONEY: Wow.
JEFFREY VAN GOGH: So I always like
to see what cool things people do with language and the tricks
you can do with it.
But I think even for people who are just writing programs
for a living, not necessarily programming language geeks,
it makes it a lot more fun because you
don't have to write all the boilerplate code.
LAURENCE MORONEY: I see.
JEFFREY VAN GOGH: Java is very verbose.
When you write a--
let's say you have a class that's describing a customer.
You have to write all the fields and all the getter and setter
methods, you're get hash code, the equals.
In Kotlin, that's just one line of code.
And it will generate all the boilerplate
and make sure it is correct.
And so that's just one example.
There are so many things where they made sure
that you have to write less code, that it's less buggy.
You don't have to worry as much about null pointer issues
because they track all the null pointer information
and give you compiler errors if you mess it up.
LAURENCE MORONEY: OK.
And just going back to that moment at I/O
when we announced it, it was such a surprise,
not just for people outside of Google, but many of us
inside of Google.
And it's like I sit really close to you here at Kirkland,
and I had no idea.
I was sitting in the audience, and it just blew my mind
that you're supporting Kotlin.
JEFFREY VAN GOGH: We really wanted to keep it secret.
We didn't want it to leak.
We wanted a big surprise.
And also, we needed a time to make sure
that everything went through.
We wanted to make sure we had a good deal set up that protects
the future of the language.
And so we wanted to make sure that we did everything right
before we announced it.
LAURENCE MORONEY: It was such a surprise,
but such a great surprise.
Because social media lit up, as you probably saw,
at I/O. What's the feedback been like?
JEFFREY VAN GOGH: A lot of people love it.
We heard a lot of people saying, well,
I was worrying that I had to go argue with my manager.
But now that Google supports it, it's a done deal.
LAURENCE MORONEY: It's always good
when we prevent people arguing with their managers.
JEFFREY VAN GOGH: Yeah, it is.
LAURENCE MORONEY: As a manager yourself,
I'm sure you appreciate it.
JEFFREY VAN GOGH: Yeah, although a good technique argument--
I like to have those.
LAURENCE MORONEY: I'll bear that in mind.
So the feedback was generally very positive.
JEFFREY VAN GOGH: Yeah.
I think there was some worry about people
thinking that now we're no longer investing in Java.
But as I said, we just added a Java 8 support to enrich CO.
And we'll keep investing there as well.
We understand that it's not for everybody.
LAURENCE MORONEY: Right.
JEFFREY VAN GOGH: So we fully plan
to invest in Java functionality as well.
LAURENCE MORONEY: So if I'm a new developer, and I'm getting
started, and I'm starting with Android,
and I've heard all about Kotlin and how much fun it
is, how would I get started building this?
JEFFREY VAN GOGH: So it's actually really easy
to get started because it's not a either/or choice.
You don't have to say, well, I'm going to either choose
Java or Kotlin.
You can just take an existing Java project
and add one Kotlin file and write one function in Kotlin
and keep the rest of your app in Java.
And everything keeps working.
LAURENCE MORONEY: Cool.
JEFFREY VAN GOGH: Or you could go as extreme
as writing your whole app in Kotlin
and never look again at Java.
LAURENCE MORONEY: OK, nice.
JEFFREY VAN GOGH: So you can go anywhere in that spectrum.
LAURENCE MORONEY: So in Android Studio, will
my file new project experience other Kotlin templates?
JEFFREY VAN GOGH: Yes.
So either you can-- if you have an existing project,
you can just add a new Kotlin file.
Or if you want to start with some project
from scratch, in the wizard, there will be a new check box.
And I noticed you have 3.0 and above, it says enable Kotlin.
LAURENCE MORONEY: OK.
JEFFREY VAN GOGH: And it will do all the work of adding Kotlin
to your Android griddle file to load the Kotlin plugin.
It will also create the first activity in Kotlin source.
LAURENCE MORONEY: Nice, nice.
So then if I just want to get started with Kotlin,
Android Studio seems to be the way to go.
JEFFREY VAN GOGH: Yep, yep.
And then if you're not sure if you want to try it,
there's also, on kotlinlang.org, there
is an online "hello world" sandbox.
And you can play there as well.
LAURENCE MORONEY: Oh, so the sandbox--
I can start typing code in my browser and testing it
JEFFREY VAN GOGH: Yep.
LAURENCE MORONEY: And this is on the Android developers site?
JEFFREY VAN GOGH: No, it's on kotlinlang.org.
LAURENCE MORONEY: Oh, I see, OK.
But the Android Studio I get from the Android developers,
right?
JEFFREY VAN GOGH: Yes.
LAURENCE MORONEY: So if I want to get started,
it's worth playing kotlinlang.org.
And I go to developer.android.com
to download Android Studio.
Cool.
And is there any words of advice you'd
give to developers getting out and starting with this stuff?
JEFFREY VAN GOGH: Just try it out.
It's so much fun.
You'll realize that you don't have to write
all your boilerplate code.
And coding becomes so much more fun.
LAURENCE MORONEY: Sounds great.
So thank you so much, Jeffrey.
Thanks a lot.
JEFFREY VAN GOGH: Thank you.
LAURENCE MORONEY: Thanks, everybody,
for watching this episode of "Coffee With a Googler,"
and for Jeffrey being our guest.
If you are like me, and you are just
itching to get started with Kotlin,
we've heard that's the way to do it.
The kotlinlang.org, right?
JEFFREY VAN GOGH: Yep.
LAURENCE MORONEY: And also download Android Studio.
And you can just do file new experience
and use the templates and just start coding.
So I'm really looking forward to seeing the kind of things
that you're going to build.
So thank you very much.
Thanks again, Jeffrey.
JEFFREY VAN GOGH: Thank you.