Live data from Hacker News

Android now supports Kotlin

venturebeat.com

171–180 of 225 posts

Re: Android now supports Kotlin

#171
post #92

"To get started with Kotlin, download the Android Studio 3.0 preview, open one of your existing Java files, and then choose “Convert Java File to Kotlin File” in the Code menu." You do not have to install a preview version of Android Studio, you can install the kotlin plugin in whatever version of AS you're using now. The change in AS 3.0 is simply that it will ship the plugin by default.

It doesn't need to be a preview version of AS. I'm coding with Kotlin on AS 2.3.1 and IntelliJ 16. Just make sure you configure kotlin for the project, easily done, by creating a kotlin file.

Re: Android now supports Kotlin

#173
post #2

Funny, I was messing around with Kotlin for the first time last night. So far, the language seems well-structured and I really like that one gets all of Java's ecosystem without actually having to write java. (Also, "override fun" just sounds hilarious. Bwaha!) Throw in TornadoFX and Gluon Scene Builder (formerly of Oracle) and you're spinning up high-quality cross-platform GUIs faster than Atom, with a visual editor…

I call Kotlin Android's Swift.

Heaven forbid they just support Swift instead.

Re: Android now supports Kotlin

#174

Earlier quoted context omitted.

Not sure what you're rambling about. Java is still and always will be the core language of the JVM. It isn't going anywhere and the Java team (comprising mostly ex-Sun people) continues to push the language forward under Oracle's fantastic stewardship. The issue is that Java is required to be more stable than other languages since it powers so many production, enterprise system and hence will be slower to innovate. I…

I think the Oracle/Google lawsuit drove the decision to adopt Kotlin. Now Google is going to work with JetBrains to develop Kotlin and is going to fork the GPL JVM probably by not including things like the controversial project Jigsaw that IBM voted down. Meanwhile, Oracle is stuck with Java, just like they're stuck with OpenOffice, Hudson, etc.

Nah. What drove the decision is that huge swaths of Android development community already adopted Kotlin and it's trivial to implement it in existing Android codebases. It's also built by a company with which Google already has partnership with (IntelliJ built both Kotlin and IDEA IDE which is the base for Android Studio).

Re: Android now supports Kotlin

#175
post #42

I wonder if Android will ever support Go? Seems Google would want to do this.

Go (like other non-JVM languages) doesn't talk to Java APIs well - the JNI bridge is ugly and adds a severe performance penalty. Short of actually rewriting Android itself, it's probably not going to happen.

Re: Android now supports Kotlin

#176
post #23
post #5

Well this looks like going to push Kotlin in big league. I remember scala enthusiasts made big noise in last few years to have scala as officially supported language. But Google seems to prefer a closer relationship with Jetbrains.

I don't see what it has to do with relationships. Convince us why Scala would've been a better choice?

Objective-sounding reasons: Scala has got a large library ecosystem, it's demonstrated an ability to retain backwards compatibility while evolving the language (Kotlin may yet get this right (well, no it won't, but that's getting into a more technical argument) but many languages don't, and Kotlin simply hasn't been around long enough to see whether it's any good at handling change).

Developer reasons: Scala is a much more elegant language. Failure reporting in Kotlin completely sucks (in some ways it's worse than Java since they've removed checked exceptions and not offered any substitute - they make a lot of fuss about handling null/options but all that completely breaks down as soon as you want to actually report a reason why something failed). Typeclasses with automatic derivation are really nice. In a big application I might like to be able to do FRP stuff or async pipelines; not only does Kotlin not have an equivalent to fs2 but it's impossible to write one in the language. Every time a new thing comes along Kotlin adds it into the language as a new, different feature because they're allergic to offering general features you could use to implement things yourself (e.g. async/await).

Re: Android now supports Kotlin

#177
post #106

Earlier quoted context omitted.

The newest version of Scala (2.12) requires a JVM with Java 8 feature compatibility which makes it unusable on Android devices. Google would literally be stuck supporting an obsolete version of a language that's not developed... or restrict the use of it only to Android O and newer making it dead on arrival. Kotlin compiler generates code that's runnable on JVMs supporting Java 6, which makes it work on pretty much a…

Bit of an aside, but is the Kotlin compiler itself runnable on JVMs supporting Java 6? So you could compile on an Android device.

I think you need JDK8 to compile Kotlin, but I'm not 100% sure.

Re: Android now supports Kotlin

#178
post #71

Earlier quoted context omitted.

I have nothing against Kotlin. It seems to be coming out of nowhere to surpass more "tested" languages for lack of a better way of putting it, but as I'm reading about it I can truly see the appeal. The one thing I'm having trouble figuring out, though, is how much it diverges from Java in terms of inheritance, traits, etc. The verbosity of Java is one thing, but its inheritance system is what made me want to pull my…

It's weird you'd accuse Kotlin of throwing stuff at the wall while simultaneously speaking kind of Scala. Scala has so many competing ideas & approaches just all mashed up into a blob.

This is wrong. It might look like that from afar, but what seems like complex features in Scala are almost always actually combinations of simple, powerful features, and the combination works exactly the way you'd expect once you understand the simple features. (Almost all of the concrete examples people give of "Scala complexity" are actually library features implemented in plain Scala, and if you get confused you can always click through to the source and read how they're implemented, because they're just plain old code). Whereas in Kotlin they really do just implement every use case as a separate language-level feature.

Re: Android now supports Kotlin

#179
post #106

Earlier quoted context omitted.

The newest version of Scala (2.12) requires a JVM with Java 8 feature compatibility which makes it unusable on Android devices. Google would literally be stuck supporting an obsolete version of a language that's not developed... or restrict the use of it only to Android O and newer making it dead on arrival. Kotlin compiler generates code that's runnable on JVMs supporting Java 6, which makes it work on pretty much a…

thought recent android's tools update meant I can use java8 on android devices... guess that requires a recent android device :(

The devices themselves still run a JVM (Dalvik and ART) that's basically compatible only with ~JRE7 bytecode. There are some new features in ART since N, but still the JVM isn't fully Java 8 compatible (afaik invoke-dynamic for lambdas is still not supported).

So the Java 8 tools you're talking about essentially take Java 8 compiled bytecode and patch out the parts that aren't compatible with device JVM (e.g. they replace lambda invocations with anonymous classes like you'd use on Java 6 etc.).

This doesn't work for things like Scala which use these new features in patterns those tools can't patch/recognise.

Re: Android now supports Kotlin

#180

I should note that Kotlin now supports JDK, JS, iOS, and LLVM as backends. Gradle also announced support for Kotlin. This means you can write your Android app, iOS app, web browser app, desktop app, and your build scripts -- finally all in the same language.

That's a pretty absurd claim, their native implementation is not only experimental, the GC solution is "unknown". You can't make this stuff up, it will be years before anyone is writing production IOS apps in Kotlin. Heck, their JS implementation still generates massive binaries. Targeting the JVM/Android? Sure, good to go; otherwise the promised land is a long way off.

"Unknown"? They have said from the beginning that it uses reference counting with cycle collection, for example in RELEASE_NOTES.md:

"Currently Kotlin/Native uses reference counting based memory management scheme with a cycle collection algorithm. Multiple threads could be used, but no objects shared between threads are allowed."

They have also said that it's pluggable and they might experiment with other collectors on different platforms, but it's hardly "unknown".

The size of generated JS is definitely a problem at the moment but they're working on it:

https://discuss.kotlinlang.org/t/kotlin-js-file-size/2501/2

Post reply on HN