Hacker News new | comments | show | ask | jobs | submit login
Get Started with Kotlin on Android (android.com)
99 points by ing33k 189 days ago | hide | past | web | favorite | 15 comments

I've been playing with Kotlin and I'm liking it, but my god Android development is such an nasty hellhole.

As good as it is, Kotlin can't fully mask the awful boilerplate and APIs .

Are you already using anko ? https://github.com/Kotlin/anko

Anything in particular stick out as bad in the API?

I haven't tinkered with mobile development in awhile, but I remember content providers feeling like an oddly thought-out concept at the time.

You can solve by building your own mobile OS with your expertise.

Great getting started page. Short and direct.

As a Kotlin noob, can someone explain to me why the Kotlin on-click listener doesn't need to specify onClick() like the Java one does?

Actually, this is similar to what you can do in Java by using lambdas (Retrolambda for pre-Java 8, e.g. Android pre-SDK 24). Excerpt from a blog post [1] about it:

  mButton.setOnClickListener(new View.OnClickListener() {
      public void onClick(View v) {
          // do something here
can be replaced with

  mButton.setOnClickListener((View v) -> {
      // do something here
which is nice for all callbacks, but especially together with ReactiveX where they are abundant.

[1] http://zserge.com/blog/android-lambda.html

Worth noting for completeness... In Kotlin you can take that a step further:

mButton.setOnClickListener { /* do something here */ }

(In addition to SAM conversions, both the parenthesis and input variable are optional.)

Kotlin and React both on the front page. Anyone can give some compelling reasons why old Android devs like me should try React Native?

Personally I don't feel the need to use React if you use kotlin. But there are few cases where React makes sense. Everything that involves a stream of events that you need to process and they can fail or you need to retry, them React is your way to go (I don't feel kotlin is ready for this use case yet). For example, if you want to use the BlueTooth API it is so easy to use it with React because of the stream of events.

People are using React for Rest requests, and for APIs where you cannot touch them it can be a good idea as it provide ways to join results of requests and other stuff. But if you control the API and it is designed to be simple and with mobile in mind, there shouldn't be uses cases where a simple request give you all you need.

It also gives consistency as you treat the same way a click event than a http request. Some people like this but I don't.

I personally didn't find a good use case to use it in my app, but you might think diferently. So, I suggest you to try it a little at least an decide by yourself.

Have you looked at RxJava/RxKotlin for working with streams?

This can get you started: http://reactivex.io/intro.html

Have you read my comment?

I would think the main use case for React Native is multiple platform development. It solves a different problem to Kotlin.

Learning curve comparable to go?

I'd say that depends on which languages you already know. Go is a smaller language in terms of syntax. No generics, not OO in the sense that it doesn't have classes and inheritance etc. But if you're familiar with the Java ecosystem and languages like Scala, or something like Swift or Rust, Kotlin should be easy to pick up.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact