Live data from Hacker News

The not so hidden cost of sharing code between iOS and Android

blogs.dropbox.com

111–120 of 335 posts

Re: The not so hidden cost of sharing code between iOS and Android

#111

I've been considering building a pwa and using a webview as a pseudo native app I know iOS support isn't great but it seems to be improving and iOS push notifications could be built separately in the meantime. How's anyone tried this approach?

Are you really asking if someone has tried putting their website inside a webview and call it an “app”?

Have you heard of Electron, Cordova and tons of other crapware that help produce so much garbage “apps” every year, it would put to shame even the most toxic enterprises in an unregulated Republican dream?

Re: The not so hidden cost of sharing code between iOS and Android

#112
post #44

I shudder to think how many people will read this headline and immediately takeaway that React Native/Flutter/Electron are terrible cross platform solutions.

That’s a perfectly legitimate conclusion to make, especially with the examples you mentioned.

Re: The not so hidden cost of sharing code between iOS and Android

#113

This is precisely the experience of my startup trying to rely on flutter. It's a constant battle. Moreover Android and iOS are different implementation with different capability with constantly evolving API. It's hard to keep cross platform code in sync many #ifdef with edge cases. Moreover with REST API architecture majority of the common code is in back-end. So building in Swift and kotlin for respective platform i…

I've been building a Flutter app and it has been fantastic. I'm using one shared library flutter_barcode and while it isn't perfect, but it shows how easy it is to create native solutions for both platforms and marry them within Dart/Flutter itself.

I can't see how duplicating code in Swift/Kotlin would be any better than just writing it once in Dart. Dart is also quite a nice language to work in. Easy to get up to speed and a nice mix of static/dynamic typing. The optional Provider api make state management a breeze, no more Stateful widgets.

I've also switched from REST to GraphQL. I was a long time hold out there, but now I really see the advantages.

Anyway, just throwing this out there as another data point.

Re: The not so hidden cost of sharing code between iOS and Android

#114
> Because this issue involved debugging multi-threaded code running back and forth between C++ and Java it took weeks to nail down!

I don’t think the issue here is the use of c++ — it sounds to me like it’s the use of c++ on problems that would have been far simpler solve on the native code ... not all problems are that way — but even where it makes sense to solve with c++, you have to be careful about the glue.

I developed and maintained cross platform c++ for iOS/Android in a previous role and the platform to native glue is inherently complicated — among the most complicated parts of the program to reason about if you get into the details of it. I solved by making this layer dead simple — you could almost never pass objects in or out — just primitive values.

The c++ layer exposed to platform was just static methods — including a bunch of methods for retrieving state and we added more static methods when new kinds of communication were required. Every c++ method grabbed the largest lock it could prior to doing anything natively (and in debug mode related methods associated with some kind of stateful lifecycle would fatalError if they couldn’t get the needed lock — the app code shouldn’t have been calling into native code in a way that violated simple assumptions about how the state was allowed to change).

Interestingly — this forced the platform layers above to comply with the assumptions needed to keep the native code simple — and helped those working on the UI immediately find out when they were violating these assumptions — things like click handlers that weren’t debounced or weren’t switching to a disabled mode after being clicked — when those click handlers invoke native code and that native code mutates state — you have a potential nightmare scenario for robustness ...

This model actually was quite straightforward to add new functionality to over time and we frequently moved decision authority over complicated logic into the native layer so that we could make it robust and cross platform ...

Re: The not so hidden cost of sharing code between iOS and Android

#116
How's was your experience in writing iOS and Android app in Cordova? I have a small community app written in Cordova+f7+vue2 which works pretty well on Android.

I want to port it to iOS now as there is some demand. I also want to add push notifications later. So far there is a inhouse API+server which serves as backend. Not dependant on Google for any services as of now; only if there is a non-firebase solution to push notifications?

Re: The not so hidden cost of sharing code between iOS and Android

#117

Earlier quoted context omitted.

React Native

Done correctly != react native. I've had to shut down and migrate 3 RN projects because of how much of a mess it is. It's not even 1.0 and is a horrible choice for important apps.

Sadists created it

Re: The not so hidden cost of sharing code between iOS and Android

#118

This is precisely the experience of my startup trying to rely on flutter. It's a constant battle. Moreover Android and iOS are different implementation with different capability with constantly evolving API. It's hard to keep cross platform code in sync many #ifdef with edge cases. Moreover with REST API architecture majority of the common code is in back-end. So building in Swift and kotlin for respective platform i…

Could you explain what you think of the pros and cons of flutter VS IONIC? I think flutter and it's astonishing number of issues on github + their lack of manpower + their lack of major features + the presence of major performance and behavior bugs + the extremely small lib ecosystem (dart) is a major, useless risk for a startup for the benefit of tech hype. (just my point of view, don't take it personally)

One of the pros of Flutter is that its popularity is growing strongly while Ionic's is basically flat: https://insights.stackoverflow.com/trends?tags=flutter%2Cion...

I haven't tried Ionic myself, but I have tried both React Native and Flutter for a small project and found Flutter to be more enjoyable and productive.

Re: The not so hidden cost of sharing code between iOS and Android

#119
post #45

TLDR - it's too hard to find senior C++ mobile devs. I'm more intrigued by AirBNB moving away from React Native - the linked article says "RN was too small a component to bother supporting, and the developer experience wasn't up to par", but I'd like more detail than that. I've been working with Flutter for the past 6 months, and it would definitely be my "go-to" for any mobile application. To be fair, I did spend 2…

AirBnB has a series of in depth blog posts about their decision to abandon RN. In particular this quote seemed extremely worrying to me: > While debugging, React Native attaches to a Chrome Developer Tools instance. This is great because it is a powerful debugger. However, once the debugger is attached, all JavaScript runs within Chrome’s V8 engine. This is fine 99.9% of the time. However, in one instance, we got bit…

The best is when the app runs faster while debugging than it does on the phone because of this exact issue. I found it nearly impossible to profile sanely

Re: The not so hidden cost of sharing code between iOS and Android

#120
I often struggle trying to explain to more junior developers that there are times when it's OK to write code more than once. There is a mindset that you should only ever write code once. It exists for (very) good reason. But if you follow it dogmatically, you may end up with an unmaintainable tangle of dependencies that can only be resolved with a rewrite.

Sometimes, it's OK to write the same thing twice if the alternative is a major refactor - such as inventing your own stack.

Post reply on HN