Re:Kotlin, the Swift of Android
by richardwhiuk on Monday September 01, 2014 @11:21AM
(#8253269)
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.
[ Parent
| on HN ]
Java 8 does introduce a few features that are available in Kotlin, but AFAIK Java 8 won't be available for Android for some time. In addition, Kotlin makes a lot of constructs more succinct, including but not limited class definitions. So it's not only about what it adds, but what it "takes away" too IMHO.
Re:Kotlin, the Swift of Android
by higherpurpose on Monday September 01, 2014 @12:06PM
(#8253505)
> AFAIK Java 8 won't be available for Android for some time
Pretty sure it will never be available on Android. Best case scenario Google moves away from it. Worst case, it will add some new, similar features to Dalvik VM. But I doubt they are considering adopting Java 8.
Do you have any basis for these claims? Java 8 contains many useful language improvements and Google has shown with Java 7 that it will adopt these (albeit incredibly slowly)
Remember the Google/Oracle lawsuits over the use of Java technology in Android? Bringing in JVM changes from newer Java releases risks giving Oracle grounds for another lawsuit (covering the patents and whatever copyrights may apply to the new features), and it's not likely Google wants to run that risk.
(This is why the Java 7 features that they have adopted are the "syntactic sugar" that doesn't require JVM changes, and leaves the code running in the phones as-is.)
Re:Kotlin, the Swift of Android
by frowaway001 on Monday September 01, 2014 @01:28PM
(#8253886)
It has only adopted Java 7 features which are either syntactic sugar or library extensions. (E. g. everything where the Java class file version wouldn't have mattered anyway).
Java 8 (and Java 9 and Java 10) are completely different, with huge, mandatory changes to the class file format and the virtual machine.
Kotlin could be the Swift for Android if Jetbrains make it an explicit goal and gain developer mindshare.
Also, Kotlin can compile down to JS and can thus target another Google platform - ChromeOS/Chrome - with the possibility of shared code.
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.
In fact Kotlin doesn't have reified generics. This idea was planned in the beginning and was reflected in the old docs but abandoned later. I believe there's no reference to reified generics on the new web site anymore.
Huh, you're right! That's a pity
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
If you 'folded' Kotlin into Java what would you gain over just using Kotlin?
Re:Kotlin, the Swift of Android
by richardwhiuk on Tuesday September 02, 2014 @08:42AM
(#8257168)
Interop with existing code, access to a large developer, infrastructure and mindshare - especially in enterprise where take up of new languages is more considered?
java's impl of lambdas is much uglier and feels hackier than kotlin. java forces everything into a stream + checked exceptions are problematic.
also java 8 doesn't have eatures like string interpolation, default params, etc.