Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Android Applications with Kotlin (hadihariri.com)
28 points by hhariri on May 21, 2013 | hide | past | favorite | 14 comments


Quick summary of Kotlin and why you'd want to use it in Android:

  Lambdas
  Fairly lightweight, probably looking at 10% overhead only
  Can ducktype existing classes. eg add "hello".reverse()
  IDE support in Jetbrains (but not in eclipse)
  Can turn 'try..finally' into library methods
  Full interop with java files in same project
  val/var types help to reduce side effects


In addition it removes a lot of boilerplate code with things such as automatic casting. Adds null safety.


For me it's the function expansion syntax.

  fun main(args : Array<String>) {
    val a =  calculate(1) { x -> 10 + x } //11
    val b = calculate(2) { x -> 20 * x } //40

    println("a = $a, b = $b")
  }

  fun calculate(a : Int,  calc : (Int) -> Int) : Int{
    return calc(a)
  }


How does it perform? IIRC, startup time suffers when using Scala or Clojure on Android. Is that the case here?


We've not run specific tests yet for Android, but, unlike Scala, our runtime is small and the code performs as fast as Java on most benchmarks.


Sounds promising. I'll give it a shot.


I can only recommend that you take all the claims from JetBrains employees about other languages with a large grain of salt.

Having watched most of their presentations, it seems to be a sad fact that they can't seem to sell their language without spreading FUD and making misleading claims about their “competitors” (especially about Scala it seems).

I can totally understand how frustrating it must be for the Kotlin devs that they have still failed to produce anything which could be described as a stable, working release, but I think the right solution for them would be to spend less time bashing other languages and to work harder, not to badmouth and disrespect other open-source communities, their work and their projects.

If you are interested in Scala on Android in particular, there is a whole mailing list dedicated to it: https://groups.google.com/forum/#!forum/scala-on-android


I wrote a river of news reader called Android Rivers based on Kotlin - the github code is here http://goo.gl/FdEPw.

The app is available at Google Play http://goo.gl/kShgp (I made a new release today).

Feel free to evaluate the "start up" performance of my app.

My only problem with Kotlin so far is I haven't managed to figure out how to run ProGuard with it to reduce the APK. The Kotlin lib itself is pretty reasonable(less than 500KB).

Edit: add technical profile of Android Rivers

  Using SQLite database
  High performance XML parsing(RSS 1.0/2.0,ATOM and OPML)
  High performance JSON parsing(RiverJs)
  Media Service (custom podcast player)
  Writing Android Service
  Accessing Android Clipboard
  Fragments
  Implementing Holo theme in Android 2.2 above
  Library modules
  First class Outliner UI support
  Asynchronous operations
  Managing file system
  Creating custom dialogs
  Implementing Sliding Menu
  Asynchronous HTTP calls
  Integrating Android Java library
  Implementing Arabic language support


I didn't take what hhariri said as FUD -- it only confirmed what I'd heard elsewhere.

And since I don't evaluate technologies on claims alone, trying Kotlin out can't hurt.


https://news.ycombinator.com/item?id=5747657 (the similar user names seem to be a funny coincidence, I'm not related to that person in any way)


That was certainly interesting, but it seems far from conclusive. It's an Android beginner saying that everything seemed to work alright. Is he/she in a good position to evaluate startup performance?


> Is he/she in a good position to evaluate startup performance?

Even my grandma would be in a good position to evaluate startup performance.

Anyway, I was building an app back in the time of Android 2.0 to discover the platform and I had no problems, neither with startup time nor with apk size.

That's why I get a bit concerned when people who a) build a “competing” language and b) only seem to know Scala from reading stuff on the internet, make misleading claims. If this had just happened once I wouldn't have said anything, but this seems to become a pattern.


I'm a Web guy starting to learn Android, and thinking of using Scala, may I know how bad the startup time when using Scala (and other problems if you know any)? My understanding is you can use ProGuard to slim it down and make it as fast/small as Java.


I really recommend Kotlin. Check out the Kotlin code on my app goo.gl/FdEPw and you will see the difference between Java and Kotlin.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: