6 ms·
I like this as a thought experiment - can I write JS code (specifically using React) that can be shared across a variety of devices. At the same time, I would n
by Flux159 11y ago
I like this as a thought experiment - can I write JS code (specifically using React) that can be shared across a variety of devices. At the same time, I would not do this for any sort of non-trivial production application. The main reason being that you're going to end up writing platform specific logic at one point or another (basic example: Handling files on the web vs on mobile - ios / android vs via node webkit). I think that the codebase is already doing something like this with its .ios.js files.
Eventually you'll end up with some shared code and other platform specific code and you'll wonder why you don't just split up the codebase into individual applications (that can easily be worked on by independent teams). You can still have a shared dependency that handles logic, but you can iterate on each application independently.
- bryanlarsen 11y agoVery few large multi-platform applications use separate code bases. Why should it be different for a javascript/React app?
- Flux159 11y agoI'm assuming that you mean Linux/Windows/MacOS when you say multiplatform. I agree that for Desktop apps its sometimes okay to use the same codebase (thinking of Blender, Gimp, other open source apps that work across Desktop OSes). Other times there are apps that work significantly better because they utilize an OS's strengths (Pixelmator for MacOS). The key difference here is that user expectations are completely different between a mobile app, a desktop app (either native or node webkit), and a web app - at the moment I would say that its rare to see any app share the same codebase (not including shared libraries/dependencies) for all of those. As this post shows, its not impossible, but there are still some tradeoffs. If I was starting a brand new application that needed to work across all platforms, I would still consider having independent code bases sharing a library as a dependency rather than having a single codebase for everything - especially if I wanted to be sure to have the best possible experience for each platform.
- bryanlarsen 11y agoIn the example app, the mobile variant has completely view code than the two web based variants. The fact that they look and feel similar is a deliberate coincidence more than a consequence of the design.
- ericflo 11y agoThe whole "write a shared library, and layer your platform-specific UI on top of it" sounds great in theory and is brought up all the time, but vanishingly few apps actually do this from what I can tell.