react-native-community / discussions-and-proposals

Discussions and proposals related to the main React Native project
https://reactnative.dev
1.68k stars 127 forks source link

react-native using flutter as a compile target? #153

Open cs224 opened 5 years ago

cs224 commented 5 years ago

Hello there!

I have tried to search for this topic via google, but if you type "react-native" and "flutter" you always get a "vs." comparison.

I am a big fan of react.js for web development, but am new to app development. I've done quite a bit of research and implemented basic test applications in both frameworks. What emerges in my mind right now as a "perfect scenario for the future" would be if react-native would use flutter as a "compile target". This would serve two purposes:

1) I can continue to write my app logic in JavaScript/TypeScript and rely on the npm eco-system like I do today.

2) IFF I ever were in the need of writing components that do not exist in react-native I could do it in flutter and only would need to do it "once" rather than twice for android/java and ios/swift,objective-c.

As additional benefit I would see that react-native would nearly automatically profit from any improvements in the component library of flutter.

What I really dislike about flutter is that it forces me to use ANOTHER programming language and that I cannot re-use the npm/JavaScript eco system.

I am sure that I am not the first one with this idea, but as said above: you cannot use a search engine to find a community that is maybe already working towards such a goal. Could you please provide me with some pointers in the right direction?

Best regards, Christian

RWOverdijk commented 5 years ago

That sounds like a very difficult thing to accomplish, given I understand it properly. React Native actually runs javascript, it doesn't convert code (like NativeScript for example does).

Flutter runs its own thing, including UI components. So I'm not entirely sure how this would work.

Could you explain what this would look like? Would flutter run javascript? Or.. I don't know :p

cs224 commented 5 years ago

I am no expert in neither technology, but my imagination would be to use the same approach that reract-native uses right now with the native targets like ios.swift or android.java.

I've heard that react-native uses the so called bridge to talk to the native side. I would imagine to plug-in flutter the same way as for example swift is a target. As flutter is open-source all the bits and pieces should be available to integrate that part even deeper, e.g. perhaps even making the bridge unnecessary.

For how to do that, I believe, there would be several ways:

pvinis commented 5 years ago

I guess it's possible, but why? 😬

mehdi-cit commented 5 years ago

Hello, I came to this board to ask this exact same question. Only learned about flutter yesterday and it does have some strong arguments on its side. I mirror @cs224 opinion and I really want to know whether it's possible and desirable to target flutter. This way -at least in theory- whatever improvements flutter brings, react native would almost instantly be able to benefit from. Here we take advantage of React multi targets wrapping paradigm (if i may say so) to ensure React Native always has the upper hand ... by design. NB: The only downside react-native would have in comparison to what it's wrapping/targeting is that the resulting app would arguable be slower. In most cases, this slight overhead won't matter anyway! @cs224 Also, the most important feature that react native has in comparison to Flutter is the Over-The-Air updating capability. So, the way I see it, React Native should keep this feature when targeting anything, including Flutter! Cheers~

kneza23 commented 5 years ago

I think at least it can work the same way as Unity can. You can create a native method on opening a new screen that can start Flutter process in it. And then all the UI functionality will be delegated to the Flutter. Not sure about communicating between both worlds.

elicwhite commented 5 years ago

What features or behaviors are you most excited about getting from React Native rendering to Flutter?

kneza23 commented 5 years ago

What features or behaviors are you most excited about getting from React Native rendering to Flutter?

Well @cs224 said that it would be cool to program a feature that is not supported in react native, in Flutter/Dart (if it is possible) instead of doing it twice on both native platforms.

cs224 commented 5 years ago

Besides what I said above:

I have too little real-life experience with both react-native and flutter, but what I read in the "vs." comparisons is that one of flutters advantages compared to react-native is its comprehensive (and rapidly growing) set of widgets coming from one source (Google) rather than the community supported approach of react-native with sometimes questionable perspectives on how well supported these components will be.

The other thing that worries me around react-native are the reasons for "Sunsetting React Native" by Airbnb. From my understanding of their issues the problem could be considerably mitigated by using flutter as a "compile-target" (I am aware that there are efforts underway to mitigate their issues on other levels, too).

wamry commented 4 years ago

react-native using flutter as a compile target

yeah, with some some native code on top, will make a great spaghetti

sarath263 commented 4 years ago

Is it possible for react native team to create a compiler(using JIT in v8 engine) such that jsbundle transformed to executable binary(like jar, exe etc. etc.)

Yes, I am asking for a real JS 'compiler' instead of 'interpreter'. Just like flutter.

Need experts on v8 engine to create something like the same.

Takeaways

No dependency on web engines on different platforms React Native will serve with js runtime.(Full js compiler)

To do

React bridge might need to be rewritten in a compiled language/compiled as a binary executable.