Live data from Hacker News

How Discord achieves native iOS performance with React Native

blog.discordapp.com

101–110 of 115 posts

Re: How Discord achieves native iOS performance with React Native

#101
post #51

Earlier quoted context omitted.

> Is that really true? ‘react-native init AppName’ and your ready to go? If you already know React/Redux/etc, perhaps. Else "Ready to go" after reading about several concepts, libraries, and systems and getting how the work together, what performance pitfalls they have, etc...

If you would initiate a Swift app or any other for type of app for that matter, what language/frameworks give you a complete solution with state etc done for you. I guess I’m asking; what other solution have you found that solves everything for you?

If you want to build an iOS app with Swift, the built-in frameworks give you everything you need. Swift as a language, Cocoa Touch (includes Foundation as a kind of standard library and UIKit or SwiftUI for the UI stuff), Xcode for the IDE and build system. There's one source of documentation, Apple, and there's years of third-party documentation all over the internet.

You can bring in libraries of course, but even for a large iOS project it's unlikely (and probably unnecessary) to have more than a handful.

Re: How Discord achieves native iOS performance with React Native

#102

Once i have a dream about RN application for iOS/Android without Xcode and AndroidStudio. Started with Expo, great tool if you don't have native modules. But i have, very complex search library in Rust. After few attempts the code was converted to asmjs (RN doesn't support wasm). So i have JS-only codebase that works on Expo. Livecoding (a bit slow beause of large js codebase) and easy deploymnet on all platforms. Af…

May want to also look at MS/Xamarin development, I know a few people that really like it. Though, RN seems a bit more popular. For that matter, in what ways is JS unpredictable? Generally combined with Redux or something similar, I've found it to be fairly consistent and predicatble.

About JS, i made wrong assumption that we entered v8 era and my number crunching code should work reasonable fast everywhere.

Re: How Discord achieves native iOS performance with React Native

#103

React Native is excellent for web teams that are creating a new mobile app. If your team has more experience with React than native iOS/Android, then it's a no-brainer. However, in my experience you get diminishing returns once your app has passed v1 and your customers expect more after the new-ness wears off. You find yourself spending more and more engineering effort to make your RN app to feel as good as existing…

As a full-time native app developer on both platforms for 10 years, I find this argument odd.

It’s trivial to interface existing native code with react-native. I’ve “merged” two existing apps written on both platforms into react-native apps by adding only a small amount of JS (and some native RN interfacing) with removing zero native code on either platform. Likewise, I’ve started with full Javascript apps and slowly replaced the JS with native code where perf mattered or RN was lacking.

You can choose how much “react-ness” is in your app quite easily, and to me this is the real game changer for react-native.

Re: How Discord achieves native iOS performance with React Native

#104
post #81

Some people, when confronted with having to develop a mobile app on Android and iOS, think “I know, I'll use React Native.” Now they have three problems: Android, iOS and React Native. My company has both natively developed Android and iOS apps, as well as a few RN apps. I'm in the developer tooling part of the company. Indeed, the RN apps did allow those teams to add developers who had only JavaScript coding experie…

React-native allows native developers to work faster. It is far from ready for anyone without native experience to be used in a production environment.

Re: How Discord achieves native iOS performance with React Native

#105
post #16

The iOS app of Discord is crappy compared to the Android app. I mean, it's not bad bad, but it's not good, or at least not as good. I wonder why they decided to go this route instead of hiring iOS developers? I could understand if they used the same app for both platforms (like they do with their Electron app, which is also not as good as Ripcord), but since they have a native app for Android...

Our core team - and indeed our original team - were native developers not React JS ones.

We chose React Native because it was a pragmatic choice and the best tool for our situation. As our startup gained traction and we decided to build mobile apps - we already had a React JS app so it made sense to try out RN.

As it turns out, we were able to build an almost feature parity versions of the React app in a weekend that shared all the business logic - so it made a ton of sense for us.

React Native for Android did not exist at that time (not open sourced) and so I had to build out our initial Android app in native - I can tell you it took me a lot longer than a weekend :P

That isn't to say there are not pros and cons to each approach - but I think it's important to be always open to new tools/languages vs. going with the "devil you know" so to speak.

Re: How Discord achieves native iOS performance with React Native

#106

React Native is excellent for web teams that are creating a new mobile app. If your team has more experience with React than native iOS/Android, then it's a no-brainer. However, in my experience you get diminishing returns once your app has passed v1 and your customers expect more after the new-ness wears off. You find yourself spending more and more engineering effort to make your RN app to feel as good as existing…

As a full-time native app developer on both platforms for 10 years, I find this argument odd. It’s trivial to interface existing native code with react-native. I’ve “merged” two existing apps written on both platforms into react-native apps by adding only a small amount of JS (and some native RN interfacing) with removing zero native code on either platform. Likewise, I’ve started with full Javascript apps and slowly…

Would be great material for a blog post as adding react native to an existing project is super undocumented.

Re: How Discord achieves native iOS performance with React Native

#107
post #98
post #50

Earlier quoted context omitted.

how did the java interop work for you ? I used to work in a company that used that approach with gomobile (golang) , and frankly the dark magic required to have a decent java API to the shared library made me want to not touch that with a ten foot pole. I believe it was due to JNI but my memories may be wrong.

The answer is in the parent's comment. They used protobufs, so I guess there's no JNI, just a simple RPC over a local socket.

Thanks, i completely missed that part. Very interesting solution...

Re: How Discord achieves native iOS performance with React Native

#108
post #50
post #24

Earlier quoted context omitted.

This is the approach we took at my current and previous mobile projects and has proven to be very effective (we chose C++ due to toolchain maturity over all platforms): - It forces you to think about your business logic vs. UI structure. - It forces you to make your core logic library easily testable. - Since you can deploy the core logic library anywhere, you get native, no Electron bullshit, support for pretty much…

how did the java interop work for you ? I used to work in a company that used that approach with gomobile (golang) , and frankly the dark magic required to have a decent java API to the shared library made me want to not touch that with a ten foot pole. I believe it was due to JNI but my memories may be wrong.

We used Dropbox' Djinni for a long while and it was good for most cases, but there were performance limitations - we switched to protobuffs over byte[] arrays for complex data later.

Re: How Discord achieves native iOS performance with React Native

#109
post #68

Earlier quoted context omitted.

i highly doubt apple will port that to android, so unless they open source the technology...

It uses standard (or about to be standard) Swift language features, mainly the ability to write DSLs. Maybe other developers who really really love Swift and SwiftUI might port it to their preferred platforms. :)

> It uses standard (or about to be standard) Swift language features, mainly the ability to write DSLs.

that’s not the hard part, and apple knows it ^_^

it will be interesting when/if someone manages to get something close to apples implementation working, though my guess is they will have a “not fun” time trying to reimplement every ui interaction satisfactorily...

Re: How Discord achieves native iOS performance with React Native

#110
post #106

Earlier quoted context omitted.

As a full-time native app developer on both platforms for 10 years, I find this argument odd. It’s trivial to interface existing native code with react-native. I’ve “merged” two existing apps written on both platforms into react-native apps by adding only a small amount of JS (and some native RN interfacing) with removing zero native code on either platform. Likewise, I’ve started with full Javascript apps and slowly…

Would be great material for a blog post as adding react native to an existing project is super undocumented.

the official docs worked for me.[0] Biggest “gotcha” in my experience is version mis-match hell. Each major RN version supports a very precise version of Xcode and Android build tools/targets etc. Read the RN version release notes and you’ll be okay.

[0]https://facebook.github.io/react-native/docs/integration-wit...

Post reply on HN