Hacker News new | ask | show | jobs
by nathan_f77 3325 days ago
I've avoided writing React Native modules in Swift because I don't want to add the Swift runtime. It would make my app a lot bigger, and while I love Swift, I'm fine writing a few lines of code in ObjC.

Will Kotlin add any extra data to an Android app? Does it have it's own runtime, or does it just compile down to the same bytecode as Java?

If the app size is equivalent to Java, then this is amazing. I love Kotlin, and will write all of my React Native libraries in it (as soon as there is some support.)

UPDATE: Looks like the Kotlin runtime is around 859KB. Maybe smaller after ProGuard? In the grand scheme of things, that's smaller than many web pages. But it's probably not suitable for an open source library.

I don't think Facebook would rewrite React Native in Kotlin. I've heard that they might be moving towards C++, so that more code can be shared between the different platforms.

1 comments

Rewriting React Native with Kotlin would make a lot of sense. Kotlin compiles to Java bytecode, so you don't need to deal with JavaScript engines, serialization/deserialization, etc. Kotlin will compile to machine code, so it'll be supported with iOS with the same advantages. Kotlin performance is better than JavaScript. Kotlin has async constructions, etc. Kotlin could be compiled to JavaScript for web apps, so code reuse will work.

The only thing that Kotlin misses is XML Tags inside the language, but they could be modeled with DSL API.

That said, I don't think that Facebook would rewrite react native. It's an impossible task and they don't really need it. But I hope that some big player will replicate react native with Kotlin.

> Kotlin compiles to Java bytecode, so you don't need to deal with JavaScript engines, serialization/deserialization, etc.

I don't think the GP meant replacing JS with Kotlin, rather they're referring to implementing React Native modules in Kotlin instead of Java, keeping the JS part untouched. (As you may know, React Native modules/components require native implementations before they can be used in JS).

I hope that clears things up a bit!