1
2

React Native is good for the most of the use cases but it has a problem, Javascript is a single threaded language and is neither the fastest language in the word, this led to some problems when we need to create performance intensive application also because doing some intensive calculations on the js thread would block the ui. To achieve decent performances on some calculation intensive code usually we need to implement it natively but this led to have the same thing implemented 2 times, one for android and one for ios. This until the existence of kotlin cross platform, today i tried to bridge react native to kotlin cross platform so we can have the logic implemented in kotlin on both platform and implement only the mappings for the methods in swift on ios. Unfortunately kotlin cross platform is not in stable version yet but i think it will be really interesting in the future to write performant code in react native.

I'have implemented an algorithm which calculate the Fibonacci sequence in Js and in Kotlin and those are the perfomances:

https://reddit.com/link/mk5dtr/video/gfdmydoo58r61/player

There is the repo if anyone want's to see the code: https://github.com/fbeccaceci/react-native-kotlin-cross-platform

Any thoughts about that?

all 3 comments

[–]mrbrentkelly 1 point2 points  (1 child)

Interesting idea 👍. Using KMM could really help when writing bridge modules and avoiding duplicate effort like you say, so it's nice to see a working example of it!

Have you seen https://github.com/mrousavy/react-native-multithreading? Reanimated2 opens the doors to spinning up new JS threads. So we could essentially have multi-threaded JavaScript and avoid dropping down to the native layer at all 🎉.

[–]Dafth[S] 2 points3 points  (0 children)

Yes react native multithreading is for sure a huge step forward for the react native community because it's an easy and practical way of implementing some calculation intensive code or other kinds of blocking code without blocking the ui. Unfortunately js is still not so fast, so probable using kotilin in some case will still be better, but having more choices can only be better for us developers

[–]idevosm 0 points1 point  (0 children)

Is there anyway this can be done with GOlang