Kotlin: the Upstart Coding Language Conquering Silicon Valley
You’ll find millions of apps in the Google Play store, many of them written using the powerful, stable, workhorse programming language Java. If it were a car, Java would feature a fast, reliable engine but not antilock brakes, power steering, or cup holders. Totally drivable. Not exactly a joy ride.
In May Google gave Android developers another option when it announced it would start supporting a new programming language called Kotlin, which offers most of the same basic features as Java plus the coding equivalent of seat warmers and a killer sound system. This means programmers can write safer, more reliable code with less work. That’s good news for users because it should translate into apps with fewer bugs and crashes. But it’s even better news for programmers, because it means spending more time working on the interesting parts of code and less on more routine matters—the things that make programming a rewarding career or hobby. “Working with it just brings a smile to your face,” says Christina Lee, an Android developer at Pinterest and Kotlin enthusiast.
Companies like Pinterest, Basecamp, and Square had already been using it, but now that it has the official support of Google, you can expect to find Kotlin in more and more places. “Kotlin is what our development community has already asked for,” Android product manager Stephanie Saad Cuthbertson said during the announcement of Kotlin support at Google’s IO conference in May.
Works Well With Others
Although the first official release of Kotlin came only last year, the language has a history that stretches back to 2010. It was created by a Czech company called JetBrains, which makes software for programmers and project managers. But the team didn’t make Kotlin to sell. They made it to solve their own development problems.
More than 70 percent of its products were built with Java, says Hadi Hariri, a developer evangelist at JetBrains, but most of the rest were written in Microsoft’s C# language. The team saw a lot to like in C#, and were getting sick of some of Java’s old fashioned ways. Using Java means writing out lots of code that other languages tend to handle automatically. Something as simple as printing the phrase “Hello World” can take up three lines of code in Java, but usually only takes three words in modern languages.
That means extra work, much of it fairly repetitive. And all that extra code—”verbosity” in programming lingo—makes programs more cluttered and makes it easier to make mistakes. “The biggest issue with programming languages is that when you look at some code, you’ve got to figure out what the code is doing,” says Hariri. “It translates into a lot of noise that really isn’t necessary to understand the problem it’s trying to solve.”
The JetBrains teams really wanted to use a more modern language, but they still had many applications written in Java that would need to be maintained. It just wasn’t practical to re-write all of their existing Java applications in C# or some other language. What they needed was a language that was compatible with Java, so that they could add new features to old applications using the new language without completely rewriting the applications from scratch.
A few such options existed. Scala was gaining popularity at the time, thanks in part to its use at Twitter. But Hariri says it wasn’t as fast or as simple as the JetBrains crew would have liked. “It’s a very powerful language that, if misused, could end up badly,” he says. Groovy and Clojure, meanwhile, employed different programming paradigms altogether.
So the JetBrains team built their own language that had all the features they wanted and a strong focus on compatibility with Java. And instead of keeping the project internal, JetBrains open-sourced the project. JetBrains doesn’t profit directly from Kotlin’s use among developers, but the company hopes to make money off of it through increased interest in their Kotlin-supporting core products. Perhaps more importantly, JetBrains benefits from giving away Kotlin for free in the form of feedback and improvements from the larger Java community.
The company released a preview version of the language in 2011, and it turned out many other people were looking for something along those lines. One of them, Jake Wharton, an Android engineer at payments company Square, has been following Kotlin since its beginning. “Once you start using the language you can tell it was built by someone who spent a lot of time programming in Java,” Wharton says.
In 2015, he prepared a document to explain to his bosses at Square why they should sign-off on his Kotlin use. He published the paper on the web and soon many other people were using it to sell their bosses on Kotlin. “Jake’s well known in the Android community, he’s written open source libraries that we all use,” says Dan Kim, an Android developer at the software company Basecamp, says about Whaton’s paper. “It showed people that if Jake believes in it, it’s got at least a shot at being pretty good.”
But there was a catch. Although it was possible to build Android apps with Kotlin without Google’s official support, it was a risk. If Google made changes to the way Android worked, apps written in an unsupported language might not work the way developers intended. And if Google ended up announcing support for, say, Apple’s Swift or its own language Go, many managers might be left feeling they’d bet on the wrong horse. Google’s announcement last May meant that companies could adopt Kotlin without fear.
To Android and Beyond
Although one of Kotlin’s biggest selling points is that it can be mixed and matched with Java, it has appeal far beyond companies with vast amounts of old Java code they still need to use. Lee started using Kotlin at the startup Math Camp before it was acquired by Pinterest simply because her team thought it was the best language for their needs. “We started from scratch,” she says. “The app was 100 percent Kotlin, there was no Java in there.”
And its applications extend well beyond Google’s platform. Like Java, it can be used to write apps that run on desktops and servers as well. Plus, JetBrains has released tools for translating Kotlin code into code that can run on iOS or even in web browsers. All of which is to say, you can expect to find yourself using apps written in Kotlin more and more often in the coming months and years. Let’s just hope those virtual cup holders to bring a smile to users’ faces as well as coders’ faces.
via Wired Top Stories https://www.wired.com
July 18, 2017 at 07:12AM