Live data from Hacker News

How Discord achieves native iOS performance with React Native

blog.discordapp.com

51–60 of 115 posts

Re: How Discord achieves native iOS performance with React Native

#51
post #3

I recently tried to start a react native / typescript project, but the ecosystem confused me a lot. The various different tool recommended to create a project, some project templates not even compiling, the tons of different utilities required to process source files.. All that and not a single reliable source of documentation, made me feel it would be a real nightmare to maintain on the long run.

Is that really true? ‘react-native init AppName’ and your ready to go? What is wrong with react natives official documentation? I think what many mess up(me included) is to look at the wrong version of the documentation. I guess that could be a little bit more obvious. edir: oh, typescript! Yeah, that is a little bit more troublesome; https://facebook.github.io/react-native/blog/2018/05/07/usin...

>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...

Re: How Discord achieves native iOS performance with React Native

#52
post #11

Earlier quoted context omitted.

Watching some videos illustrating writing iOS React Native apps using Clojurescript, with REPL changes updating app display in real time (well, "live") is what makes me interested in RN. Were it not for that, I don't see why Swift is such a bad thing. I know that maintaining two separate code bases for iOS and Android is theoretically bad, but I imagine if the apps are architected well it shouldn't be such an issue.

> I know that maintaining two separate code bases for iOS and Android is theoretically bad I'm not sure _why_ this should be theoretically bad. It depends what you're going for, of course, but cross-platform GUIs are typically... not good. There's a lot to be said for separate GUIs with shared business logic IMO.

It’s theoretically bad because you’re theoretically wasting your time and resources. In practice that doesn’t have to be true. But I merged two teams together via react-native in hopes to make them more productive and it absolutely worked.

Android is no longer a laggard with features, which was also a big goal of ours.

That said, if I were to go back and time and know how much of my own time would be spent fixing bugs in react-native just to keep the team productive, I might have made a different choice.

Edit: should also be known that I’m no longer helping with fixing RN bugs, and the team still messages me on occasion to ask questions or for help to fix things. This was absolutely not the position I was trying to leave that team in.

Edit edit: my leaving the team wasn’t within my control and management didn’t realize the level of work to Keep the Lights On nor did the particularly care.

Re: How Discord achieves native iOS performance with React Native

#53
post #3

I recently tried to start a react native / typescript project, but the ecosystem confused me a lot. The various different tool recommended to create a project, some project templates not even compiling, the tons of different utilities required to process source files.. All that and not a single reliable source of documentation, made me feel it would be a real nightmare to maintain on the long run.

You are not wrong. It is a nightmare to maintain, and if you already took the leap you best keep that project updated as soon as possible or you will be fucked beyond repair. There has to be a better way to write mobile applications. Is that Ionic? I don't know.

Just came from trying Ionic, it now has ehmmm vanilla Cordova, Ionic Cordova and then there's Capacitor. They're all sort of compatible in terms of commands and application structure so it's pretty easy to screw stuff up if you end up in the wrong docs. At other moments you really do need to dip into vanilla Cordova using Ionic or Capacitor.

Re: How Discord achieves native iOS performance with React Native

#54
post #2

I almost got an tear in my eye reading this, being heavily invested in React-Native and the worries I’ve felt since Airbnb abandoned the ship. I’ve always loved the framework and the beauty of being able to write native , cross-platform applications as a web developer. And what they are doing right now, trying to get rid of the js-thread bottleneck in 2020 excites me a lot! > “While it was closed it always had a spin…

A spinner running in the background consuming CPU is two bugs... The non-obvious one is why is the framework consuming any CPU time at all on something not visible? When an element tries to animate, and the whole element is covered/offscreen, the framework should simply pause the animation. When the element becomes visible again, it's simple to calculate how long the element has been invisible, and fast-forward the a…

On Mac OS iTunes and Finder manage to waste a lot of CPU spinning spinners while running g their backups. Apparently either it isn’t that easy or it’s easy to do wrong.

Re: How Discord achieves native iOS performance with React Native

#55

Earlier quoted context omitted.

Super easy if you know JS/TS and turns out that I actually quite like it.

What's missing? TS has quite a few interesting language features that I assume Dart is missing (seems Dart has the reputation of being a Java-like language, with all the boilerplate that that entails).

Probably my largest complaint is the need to use codegen for the json stuff. Sure you can type it all out by hand, but the codegen really does automate a lot of it for you.

I have intentionally kept my very specific use case mobile app very very simple and not gone deep on the magic edge cases. It is a private app and will never be on the store. It is basically used as a QR code scanner to track equipment.

I'm sure that if you have a lot deeper/larger apps you'd find more to complain about, but so far I'm happy enough with going from zero to full fledged app in about a month of work.

IMHO, the boilerplate argument with Java is kind of outdated (Project Lombok and modern java solve a lot of that).

Re: How Discord achieves native iOS performance with React Native

#56
post #24
post #18

Earlier quoted context omitted.

I used to be into flutter (theorically), but after seeing some bugs and performance issues, i’m now thinking the best combination would be : - write once and compile all business logic (and server and fs i/o ideally) into a portable independant libray, either in something that compiles to C, or wasm (once it’s more mature) - write native UI code using native tooling, and call the business logic library from there. Bu…

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…

> no Electron bullshit

Electron is a UI 'framework', so bringing it up is kind of a non sequitur. Your approach of a C++ core is entirely compatible with an Electron UI.

I worked on a project that had its 'core logic' implemented in C++, which we then ran that on the web in Javascript, for the same portability reasons.

Re: How Discord achieves native iOS performance with React Native

#58
I'm just gonna say. Great writeup and a good example case in performance optimizations.

Now please make discord in windows start up faster than it takes to boot windows. That's right cold starting my computer and logging in takes less time than starting discord.

Re: How Discord achieves native iOS performance with React Native

#59
post #27

Earlier quoted context omitted.

The Swift for Android and iOS makes sense but how do you "easily" share same business logic between those other different platforms?

For that I am using the compiler which allows C#, Go, Swift code to mixed. It’s really great. So with some work you could use existing C# code even in your mobile apps. I am liking it so far :)

Which compiler is this?

Re: How Discord achieves native iOS performance with React Native

#60

Earlier quoted context omitted.

You are not wrong. It is a nightmare to maintain, and if you already took the leap you best keep that project updated as soon as possible or you will be fucked beyond repair. There has to be a better way to write mobile applications. Is that Ionic? I don't know.

Seriously, take a stab at building an app in Flutter.

Never had performance issues on scroll ? The demo app on the ios app store has lagging scroll performance for a simple app on an iphone X
Post reply on HN