Live data from Hacker News

The Hitchhiker's Guide to Kotlin

nathan-contino.github.io

11–20 of 34 posts

Re: The Hitchhiker's Guide to Kotlin

#11
post #6

Earlier quoted context omitted.

On Android, it is kind of clear, Google is doubling down on Kotlin and the team is hardly motivated to move Android Java into proper Java, so long term Kotlin seems to be the only path forward. Still cherry picking features from Java 11 when Java 17 just got released, https://android-review.googlesource.com/q/project:platform%2...

Oh really? Is this still a hangover from the Oracle lawsuit stuff? I might give it a whirl and start replacing the easy stuff first. In my system the worst part is the Android app and anything that makes it easier to maintain in the long term is welcome. edit: Not sure how I missed this announcement: https://www.zdnet.com/article/google-were-using-kotlin-progr...

Oracle has nothing to do with it, given that Kotlin and Android Studio are fully dependent on the JVM ecosystem.

If that was the reason Dart would have been a better option, but I bet the Android team is not that keen on having Fuchsia take away their party, hence JetPack Composer.

Re: The Hitchhiker's Guide to Kotlin

#12

Kotlin is a really nice language. I wish it was used more especially that now it isn't just limited to the Android and Java ecosystems. Kotlin can now compile to native binaries : https://kotlinlang.org/docs/native-overview.html#sharing-cod... Kotlin can now compile to Javascript : https://kotlinlang.org/docs/js-overview.html Edit : You can even use React with Kotlin : https://kotlinlang.org/docs/js-get-started.html…

I do kotlin daily, almost exclusively including side projects.

Kotlin native has been rocky personally, I'll check back in a year.

Kotlin on Android is a must compared to Java, else you're a fool. Haven't seen any exceptions in the industry.

Kotless is okay, works, but early days.

I've seen decent backends on quarkus and kotlin.

It's a fun language, the couroutine development is pretty nice. Flow is a lot easier than Rxjava.

Re: The Hitchhiker's Guide to Kotlin

#13
post #7

Earlier quoted context omitted.

What catching up is required compared to TypeScript? Could you go in bit more details on that, I'm curious.

Ecosystem, tooling, libraries.

It's actually very good - debugging from the IDE now even works. I'd recommend building around KVision rather than raw KotlinJs (https://kvision.gitbook.io/kvision-guide/).

The main thing that can be annoying is figuring out module exports from a js library that you want to use (which is probably easy enough if you have a modern javascript background). I haven't found a library that's stumped me yet, but some are more annoying than others. Jetbrains have a tool called Dukat which will supposedly one day automate this, but for now it's not there.

Distribution size can be an issue, but it's not terrible. My current (moderately complex) app is floating at around 2MB. I haven't tried splitting it up, though that is possible.

Re: The Hitchhiker's Guide to Kotlin

#14

Kotlin is a really nice language. I wish it was used more especially that now it isn't just limited to the Android and Java ecosystems. Kotlin can now compile to native binaries : https://kotlinlang.org/docs/native-overview.html#sharing-cod... Kotlin can now compile to Javascript : https://kotlinlang.org/docs/js-overview.html Edit : You can even use React with Kotlin : https://kotlinlang.org/docs/js-get-started.html…

Does kotlin native have a std lib yet? Last I checked you couldn’t even read a file.

Re: The Hitchhiker's Guide to Kotlin

#15

Has anybody switched to mixing in Kotlin code within an existing Java Android app? I'm not a huge fan of Java but I don't know whether it will be too jarring for maintenance tasks if I have both languages as code. There is a lot of XML floating around in my app (as most Android apps have) but switching between editing that and the Java is fine. I'm keen on the idea that there would be less code and my app is getting…

Not personally but it's happening in a few apps at my current company. In my job I mix Java and Groovy and at home I've mixed Java and Kotlin and it mostly just works (I don't think you can inherit Java -> other language -> Java because things get compiled in order but that has only been an issue for me once).

Re: The Hitchhiker's Guide to Kotlin

#16
post #6

Earlier quoted context omitted.

On Android, it is kind of clear, Google is doubling down on Kotlin and the team is hardly motivated to move Android Java into proper Java, so long term Kotlin seems to be the only path forward. Still cherry picking features from Java 11 when Java 17 just got released, https://android-review.googlesource.com/q/project:platform%2...

Oh really? Is this still a hangover from the Oracle lawsuit stuff? I might give it a whirl and start replacing the easy stuff first. In my system the worst part is the Android app and anything that makes it easier to maintain in the long term is welcome. edit: Not sure how I missed this announcement: https://www.zdnet.com/article/google-were-using-kotlin-progr...

Google can say they get less bugs, and that's probably true, but I'm sure it was partly a strategic hedge in case they lost the lawsuit with Oracle as well.

Re: The Hitchhiker's Guide to Kotlin

#17

Has anybody switched to mixing in Kotlin code within an existing Java Android app? I'm not a huge fan of Java but I don't know whether it will be too jarring for maintenance tasks if I have both languages as code. There is a lot of XML floating around in my app (as most Android apps have) but switching between editing that and the Java is fine. I'm keen on the idea that there would be less code and my app is getting…

I'm (slowly) in the process of migrating an Android app from Java -> Kotlin. The compatibility with Java is pretty amazing. Mixing the two languages feels almost the same as two java files.

There is a bit of cognitive overhead at first, but that's the overhead of learning a new language. Plus I immediately see the benefits, specifically WRT optionals (?. and ?: operator).

Re: The Hitchhiker's Guide to Kotlin

#18

Has anybody switched to mixing in Kotlin code within an existing Java Android app? I'm not a huge fan of Java but I don't know whether it will be too jarring for maintenance tasks if I have both languages as code. There is a lot of XML floating around in my app (as most Android apps have) but switching between editing that and the Java is fine. I'm keen on the idea that there would be less code and my app is getting…

I haven't used Kotlin on Android, but on the server side, it does make some of the boring stuff easier if you're stuck on an old JDK - e.g., Jackson supports serialising/deserialising straight into Kotlin data classes, you don't need this if you can use Java 14+'s records, but if you're still on Java 8, it's far nicer than all the boilerplate POJOs.

As for the DB layer, I quite like JDBI which integrates well with Kotlin also: https://jdbi.org/#_kotlin

I'm not familiar with RxAndroidBLE, but they have some Kotlin examples on GH: https://github.com/Polidea/RxAndroidBle/blob/master/sample-k...

Re: The Hitchhiker's Guide to Kotlin

#19
I tried Kotlin, but I went back to Java. Interacting with Java libraries can be OK, but it can also get ugly. Using companion classes for loggers seems overkill. I didn't like having to explicitly cast ints to longs.

I ended up going back because Java's getting better--var and records help with some of the pain--the tooling is simpler and more reliable, and working with something like Hadoop was significantly harder.

Re: The Hitchhiker's Guide to Kotlin

#20
post #6

Has anybody switched to mixing in Kotlin code within an existing Java Android app? I'm not a huge fan of Java but I don't know whether it will be too jarring for maintenance tasks if I have both languages as code. There is a lot of XML floating around in my app (as most Android apps have) but switching between editing that and the Java is fine. I'm keen on the idea that there would be less code and my app is getting…

On Android, it is kind of clear, Google is doubling down on Kotlin and the team is hardly motivated to move Android Java into proper Java, so long term Kotlin seems to be the only path forward. Still cherry picking features from Java 11 when Java 17 just got released, https://android-review.googlesource.com/q/project:platform%2...

I agree. Two years ago a slide at a Google I/O talk said "Coroutines first", and coroutine scopes like lifecycleScope are Kotlin only.

Jetpack Compose is the future of Android UI and is Kotlin only.

Insofar as bringing it into the app - from most apps I know of, new code is usually written in Kotlin, and the Java code becomes legacy (which is sometimes rewritten in Kotlin). It works well enough, compatibility with existing Java was important to the Kotlin team (for adoption and other reasons).

Read the Kotlin docs for more https://kotlinlang.org/docs/jvm-get-started.html . You definitely see some of the things mentioned when using both languages, like the JvmStatic annotation etc.

Post reply on HN