Live data from Hacker News

Kotlin, the Swift of Android

blog.gouline.net

71–80 of 114 posts

Re: Kotlin, the Swift of Android

#71

I've been looking a lot at Scala and kotlin recently. Other differences aside, Kotlin has an 800kb runtime compared to Scala 2.11's 11mb runtime. That's quite a difference

Your final app with Scala may well be smaller than with Kotlin - Scala makes very high level abstractions possible, and while the standard library is large, anything you don't use won't be included in your app. Kotlin always struck me as a bit halfhearted - if I'm going to go to the effort of learning a new language, I want one that gives me a real power boost, not just a small incremental improvement.

Re: Kotlin, the Swift of Android

#72
post #38

It would be nice if more of this was folded into Java itself, rather than existing as a new language - as the author notes a lot of it is in Java 8.

Kotlin has stuff that's unlikely to appear in Java, such as reified generics - Java has already chosen type erasure generics instead. I wouldn't bet a penny that they ever change this approach if they didn't go with it from the start.

Java is getting reified generics via a really cool mechanism called classdynamic (which also enables efficient implementation of tuples). This is pretty much necessitated by value types. See project Valhalla: http://www.infoq.com/news/2014/07/Project-Valhalla

Re: Kotlin, the Swift of Android

#73

I tried Kotlin to write the first version of a small internal application used at the company I work at. On the plus side is IDE support and the fact that you can mix and match Kotlin with existing Java code. In the end though, I found the syntax "funny" in some places and slightly less verbose than Java but not enough to justify using it. The underlying Android API is so verbose that Kotlin by itself is nearly usele…

Kotlin is very similar to Scala, but far less ambitious and not as focused on functional programming. In fact there have been various posts pointing out the similarities between Scala and Swift. It's rather pragmatic but there hasn't been much interest in it so far. Perhaps things will pick up after hitting v1.0. Pitching it as a Java substitute for Android would be a clever move. Java 8 is a poor substitute for Kotlin or Scala, and on Android you're stuck on even more archaic syntax. I'd be glad to see Kotlin replace java on Android.

Re: Kotlin, the Swift of Android

#74

I tried Kotlin to write the first version of a small internal application used at the company I work at. On the plus side is IDE support and the fact that you can mix and match Kotlin with existing Java code. In the end though, I found the syntax "funny" in some places and slightly less verbose than Java but not enough to justify using it. The underlying Android API is so verbose that Kotlin by itself is nearly usele…

Google really needs to begin rewriting all Android APIs in Go. Not an easy task, but beats doing nothing, and also using something like Kotlin to make Android development slightly better.

Re: Kotlin, the Swift of Android

#75

How does Kotlin compare to Groovy for Android development? Are they similar beasts when used for Android development, as in they both need to import their runtimes?

The article touches upon that: Kotlin has a runtime you need to import, but it's significantly lighter-weight than Groovy's or Scala's, and the method-count overhead is relatively low (half that of Guava without proguard).

Looking at the relevant jars, groovy 2.3.6 is 4.3MB[0] while Kotlin 0.8.679 is 353KB[1] (there's also a 503KB kotlin-stdlib, not sure what the comparison should be to but it compares very favorably even including both)

For other references, Scala 2.11.2 is 5.3MB and Clojure 1.6.0 is 3.5MB[3]

[0] http://mvnrepository.com/artifact/org.codehaus.groovy/groovy...

[1] http://mvnrepository.com/artifact/org.jetbrains.kotlin/kotli...

[2] http://mvnrepository.com/artifact/org.scala-lang/scala-libra...

[3] http://mvnrepository.com/artifact/org.clojure/clojure/1.6.0

Re: Kotlin, the Swift of Android

#76
Any reason to use this over Groovy ? Will Groovy has a few drawbacks, i found it much simpler and easier to use than scala.I personnally prefer a quick java over something that has to much features.Anybody tried both and can compare?

Re: Kotlin, the Swift of Android

#77
post #27

Earlier quoted context omitted.

Is this limitation going away (or otherwise obviated) by ART?

Yes, but not just yet: https://plus.google.com/107130354111162483072/posts/VEy3JChn... Mentioned at about 27:55 in this podcast where a member of the ART team is interviewed: http://androidbackstage.blogspot.se/2014/08/android-develope...

You're talking about a similar but different issue: there's a fixed-size meta-information buffer, if you go above you crash. Increase the size of the buffer and you're good to go (which is what more recent android versions have done), the new ART might make the buffer dynamic instead of static (no idea).

The 65k method problem is a problem of the dex format itself, because method-invocation instructions take "the method" as a 16-bit index, it can't be fixed by the runtime, the dex format has to be changed to fix it (either by adding new opcodes or by changing existing ones).

Re: Kotlin, the Swift of Android

#78
post #76

Any reason to use this over Groovy ? Will Groovy has a few drawbacks, i found it much simpler and easier to use than scala.I personnally prefer a quick java over something that has to much features.Anybody tried both and can compare?

One reason would be if you prefer static typing.

Re: Kotlin, the Swift of Android

#79

I tried Kotlin to write the first version of a small internal application used at the company I work at. On the plus side is IDE support and the fact that you can mix and match Kotlin with existing Java code. In the end though, I found the syntax "funny" in some places and slightly less verbose than Java but not enough to justify using it. The underlying Android API is so verbose that Kotlin by itself is nearly usele…

Curious about this. What did you find funny? Was this on an Android project?

Re: Kotlin, the Swift of Android

#80
post #76

Any reason to use this over Groovy ? Will Groovy has a few drawbacks, i found it much simpler and easier to use than scala.I personnally prefer a quick java over something that has to much features.Anybody tried both and can compare?

Groovy performance is pretty poor in general and is mostly used for writing build scripts. It's a scripting language whereas Scala and Kotlin are better suited to writing large systems. Groovy seems to have stagnated outside of its use with gradle, whereas Scala continues to grow.
Post reply on HN