Kotlin:为了下一代准备的编程语言

2,979 阅读7分钟
原文链接: hackernoon.com

Rise of Kotlin: The Programming Language for the Next Generation

Please welcome our weekly sponsor Pusher to Hacker Noon! Pusher makes realtime APIs that enable developers all around the world to quickly add communication and collaboration features to their apps. Their core product enables developers to easily create features like in-app notifications, activity streams, real-time dashboards, live trackers and much more.

Today we’re going to catch up with the Pusher Developer Evangelist Zan Markan, to discuss the state of Kotlin, what drives him to do what he does, and what makes a space cowboy a space cowboy.

David: Lets start with the State of Kotlin. You recently ran a Kotlin survey of (more about the nuts and bolts here). You surveyed 2,744 people from January to March 2018 to take the pulse of the ecosystem. What results defied your assumptions? What results confirmed your assumptions? And what’s the elevator pitch takeaway of what’s going on with Kotlin?

zan: That’s right. We noticed more and more developers using Kotlin when building applications with our products so we decided to dig deeper and find out what motivates them. I found out a few surprising things.

First off, I was genuinely surprised by the love students and more junior developers are giving Kotlin. I was expecting a bigger difference between more/less experienced developers, but the new crowds are really getting into Kotlin since Google put its guns behind the community.

Another thing that surprised me, was how many people are keen to try out the features that are labeled as experimental by the Kotlin team, namely coroutines and support for multi-platform projects — about 25–30% each.

The results of the survey more or less confirmed my suspicions on how big Android is — around 80% according to our survey data. Some other surveys I’ve seen show a bit less of Android, yet still comfortably above the 75% mark. Some of that difference might be down to my network being mostly Android-focused, but the effect wasn’t clearly as big.

One takeaway is that Kotlin is an exciting language, and one that makes developers happy.

That’s quite rare (for something such as a mainstream programming language at least), and has resulted in a vibrant and enthusiastic community that formed around the whole Kotlin ecosystem.

Kotlin’s primary development is from a team of JetBrains programmers based in Saint Petersburg, Russia. What else can you tell us about its founding? And when did you first use Kotlin?

To my knowledge, Kotlin’s history is that of JetBrains wanting a “better Java” for their developer tools. Interoperability and improved productivity were some of their main goals, and no other JVM-based language at the time really fit the bill — Scala ticked most of the boxes, but the tooling just wasn’t there, and the build times were way too slow for JetBrains’ development needs.

That exact idea of a highly interoperable and better Java was why this started to attract so many Android developers (including me, having done Android since the early days).

A few years ago the Android ecosystem was mostly stuck with an old version of Java — a weird hybrid between Java 7 and Java 6, which didn’t have nice features like lambdas and was quite verbose. So people started playing with this new thing that seemed nicely interoperable and allowed for greater productivity (especially the times it didn’t break everything 😅).

That’s what dragged me into it as well — I first heard about it in 2014, and then kept a close eye on Kotlin’s development — either by playing with it in my spare time, or using it to quickly prototype things. I wrote the first production Kotlin code when working on the Pusher Chatkit and Feeds products.

Why do you think Kotlin catered to less experienced developers? And what’s to stop it from being a fad?

Ha! I don’t think it caters to less experienced developers per-se, in fact I see it as quite a similar grouping as we’ve seen with the StackOverflow survey results so nothing unexpected in terms of how the industry is developing.

We’ve also seen that it was first picked up mostly by experienced (employed) developers, and only recently started seeing adoption with students and younger developers.

I see Kotlin as a quick language to pick up. There is excellent tooling that allows us to be productive even without knowing most of it. It’s interoperable with Java, so any porting or migration can happen at your own pace. And lastly, both Google and JetBrains are doing great jobs preparing documentation and resources supporting Kotlin.

What separated Kotlin from other programming languages that you think drove its rapid adoption? And more generally, what do you think separates programming languages that gain adoption from programming languages that struggle to gain adoption?

Support from Google and JetBrains has definitely helped. On the other hand, Google decided to support Kotlin in Android officially only AFTER the massive push from the developer community, so there was already a substantial push from the other side as well.

I actually think it’s a language that appeared at the right time, in the right community — the Android community, as it matured, and people wanted new tooling to become more and more productive. Kotlin, was just there, sure it had its flaws, but it was there and good enough for people to do it right.

How do you seen Kotlin effectively competing and complementing existing languages and architectures over the next 5 years or so?

If we start with the obvious, then Java is rather easy, and Kotlin already complements it well. I believe we’ll definitely see more of that, especially when the tooling consolidates and a few “gold standard” tools emerge. One of these tools is Arrow, a functional programming toolkit for Kotlin, that developed from Funktionale and Kategory teams joining up to create something better, more complete. I think that’s going to be the trend.

As for other programming languages — on the JVM we’ll see what happens with Scala and others, and outside of the JVM world it’s still too early to tell, but I’ve seen some promising ideas about Kotlin/Native and Kotlin for multi-platform projects — both still very experimental, but some proofs of concept are there, working and quite exciting.

When Alberto Ballano’s “Kotlin Functors, Applicatives, And Monads in Pictures” made it onto Hacker News, it brought up an interesting discussion… What do you think Kotlin is a gateway drug to?

That sounds nefarious! It’s a gateway drug to modern programming languages — ones that make us both productive as well as happy.It will definitely expose a number of people to functional programming — especially with things like Arrow, and that might let some people jump into more hard core FP languages easier.

A few other things it might do is spur a bunch of Android developers to venture into web or native development, with all its cross-platform support, and also, as more and more developers pick it up as their first programming language, they will inevitably come to see Kotlin as a benchmark they measure all other languages against, and that’s also quite exciting.

In linguistics, it takes a very long time for a language, like English or Spanish, to gain adoption. And they are many dialects, but the usage of an entirely new spoken language is must less prominent than the usage of new software languages. Do you think we’ll hit an industry maturity point where the rate of new software languages declines? Or will more new software languages continue to emerge?

We’ve already seen a bunch of excellent programming languages gain some serious adoption quickly, and in the recent years — Swift, Go, TypeScript, and Rust come to mind. Each of them is supported by one (or more) large engineering organisation with substantial resources and existing developer communities behind it.

Each of them also scratched a particular itch of their organisations, and if that itch is shared by a lot of other developers then adoption happens and a language takes off, allowing it to achieve “critical mass”. That’s what happened with each of these languages I mentioned — Go for instance started when Google wanted to do concurrency well, and one of the objectives of Rust was never crash.

As for future, I think there’ll definitely be new computing paradigms, new ideas being developed (who knows, maybe Blockchain will actually become a thing someday) — that won’t be super useful with our existing tooling.
Some other examples is quantum computing or AI.

While most languages nowadays claim to be general purpose, that still doesn’t mean they are equally well suited for every purpose. We’ll see new purposes that will demand new languages.

Let’s talk about Zan the person. The first two words of the bio on your personal website read “Space Cowboy.” Do some people call you the gangster of love? Do other people call you Maurice? Do you embody the pompatus of love?

Ha, I love that song! Gangster of love, perhaps, as I don’t think anyone’s managed to misspell Zan into Maurice, not even the Starbucks staff. I also love rockets and still mourn the loss of Firefly, so that’s also kind of a space cowboy theme.

The actual story behind that “title” is that a few years ago, when I was still running a startup I founded with a few friends out of university. To look slightly more legitimate when asking strangers for money (ie raising an investment), we had business cards made for each of us.

I’m not big on titles, especially C-titles when everyone is doing pretty much everything, so I just decided to go the other way and picked Space Cowboy which is about as (in)accurate as anything. At least I figured it would be a good conversation starter.

The fact you asked about it just proves how good a conversation starter it really is.

You’ve been said to like West Coast style IPA. I’m in Colorado now and miss Laguinatis. What are your top 3/5 west coast IPAs?

I like them violently strong and ruthlessly hoppy.

Whenever I visit the West Coast I make sure to have a Pliny the Elder by Russian River, and of course Stone IPA — both draft, obviously. When closer to home my go-to would be Jack Hammer by Brewdog.

What makes a good developer evangelist? How have you gotten better at your job? What makes Pusher technology worth evangelizing?

The most important thing for a dev evangelist (any developer relations person in general) would be a genuine passion to teach, and share knowledge. Actually, it’s probably even more important to be genuine. Full stop. Developers are natural BS detectors who hate being sold things.

It’s also a great feeling when you know you’ve helped someone become a better developer.

One of the first things that I’ve had to get better at is time management. Coming from a developer background, it’s way more common to have large chunks of time that you allocate to certain tasks. My current job is way more dynamic than that, and at first when I didn’t expect that change, or adjustment, so it was quite overwhelming. Paul Graham’s excellent essay on maker’s and manager’s schedules helped me a lot.

Another useful skill that I’ve picked up is project management — with State of Kotlin for instance, most of my work revolved around setting up the survey, and creating the content at first, and then moved into more classic project management, like coordinating with other teams involved, such as design and dev (they’ve done that work, not me, thanks again — you know who you are), and finally in getting the word out in various publications, doing interviews on the Web.

Pusher’s tech is renowned for how quick it is to integrate, as well as for the fact “it just works”.

As such, it’s a breeze to evangelise. I’ve even had people come to me at a mobile development conference and tell me that their colleagues in the web team that use Pusher told them to tell me how great our Channels product is — that was exciting 😁

All in all, where does Kotlin fit into realizing Pusher’s long-term vision?

We already bet on Kotlin as the primary development language for our Android SDKs. We started with the SDKs for the new products — Beams, Chatkit, and Feeds, and we’re currently quite happy with that.

We also believe that Kotlin has one of the most exciting and engaged communities, and that’s also part of the reason why we decided to create the State of Kotlin survey and the report for it. We certainly hope that Kotlin keeps making developers happy and productive, and the State of Kotlin helps drive its adoption further!

Pusher, our weekly sponsor, makes communication and collaboration APIs that power apps all over the world, supported by easy to integrate SDKs for web, mobile, as well as most popular backend stacks. Get started.