Apple today took a shot at React Native and other cross-platform frameworks.
I have thoughts.
First, the quote in question, from their keynote (around the 40 minute mark):
"Some other frameworks promise the ability to write code once for Android and iOS.
And that may sound good, but by the time you've written custom code to adapt each platform's conventions, connected to hardware with platform-specific APIs, implemented accessibility, and then filled in functionality gaps by adding additional logic and relying on a host of plugins, you've likely written a lot more code than you'd planned on.
And you are still left with an app that could be slower, look out of place, and can't directly take advantage of features like Live Activities and widgets.
Apple's native frameworks are uncompromisingly focused on helping you build the best apps."
First, their direct claims:
That you will write more code than you'd planned on.
First off -- this is cleverly worded. Notice they don't say "...you will write more code than you would have written for two separate apps."
This statement, honestly, could apply to any software project. I've never encountered a coding project where the end result was "wow, we wrote way less code than we thought we would" ... this is an evergreen claim.
Secondly, the specifics:
- custom code to adapt each platform's conventions
This is honestly pretty rare. Mostly, it just works, because React Native uses the platform's primitives. Less than 1% of the code in any of the many React Native / Expo project we've worked on is dedicated to platform-specific UI changes. It just isn't an issue in practice.
- connected to hardware for platform-specific APIs
This is also rare, for most apps. And when this is necessary, you just ... drop into native code and write it how you would if it were a native app, and add a little bit of boilerplate to hook it up so React Native can orchestrate it.
This is a React Native strength, not a weakness.
- accessibility
Probably the most valid complaint, but it can be done in React Native and done well.
Also: some of the worst accessibility experiences I've had were on native apps in the iOS app store.
What matters is a developer actually caring about accessibility.
- relying on a host of plugins
Valid observation, but these are overwhelmingly open source.
What do you do when an Apple API has a bug? Report and wait. You have no ability to fix it yourself.
Second direct claim:
That your app could be slower
@jmeistrich went and put time into his Legend List and made it incredibly fast, using just JavaScript. The speed limit isn't React Native.
Just like accessibility, it just takes a developer who cares about performance.
The new architecture in particular opens up so many more options for performance, as well.
Sure, your app could be slower. It could also be faster, faster to market, take less time, smaller team, cost less, and allow you to build a business around it.
Third direct claim:
That your app might look out of place
Google doesn't think so. They named an Expo / React Native app the best app of 2024.
I’m rebuilding an internal web app that we’ve had since 2016. So far, I have a grand total of 1 npm runtime dependencies (jwt-token).
Our previous version of this tool, using Next, had 826 (!!!) NPM dependencies.
I also have zero build steps. Just ship the files directly to the server.
I’m using:
- Bun as a JS runtime
- Bun as a package manager
- Bun.serve as a webserver
- Bun’s websocket server for realtime
- TypeScript on server side
- JSDoc on the client side
- REMEMBER: no build steps!
- not even TypeScript in the deps
- HTML via template strings
- CSS
- Hosted on DigitalOcean droplet
- In-memory state (just a JS object)
- JSON file for persistence
- JS’s setInterval for scheduled tasks
- git to deploy
- Cursor to generate and edit code
I’ll talk more about each of these below.
- Bun as a runtime
Bun replaces Node, of course, and brings a ton of speed as a runtime.
I just install Bun and then run it
bun run ./src/index.ts
This is also how I run it on the server.
- Bun as a package manager
This is how most people use Bun.
bun install
It’s lightning fast, but also, I only have 1 runtime dep (and a few dev dependencies, which are all type related like @types/bun), so of course it’s fast.
* First years are a lot of physical work, but I can still remember that freshly bathed baby smell as they lay sleeping on my chest. One of my fondest memories and times of my life.
* Elementary years are pretty good. Some running around but we had more time where they were out at school and they also are learning to do more themselves. The introduction of more of a more rigid schedule was a big adjustment, and we had to plan trips more.
* Middle school years are harder because it’s a transition for them *and* for us — them to the complex social dynamics, and us to being a different kind of parent who can help them navigate that rather than wiping their butts or carrying them around. Also developing more complex… https://t.co/xRBXyI8RZNtwitter.com/i/web/status/1…
Want to know how easy it is to grab API keys out of a compiled iPhone app?
Buckle up. 👇
DISCLAIMER: This is for security research only. Responsibly disclose vulnerabilities you find to the relevant developers! I MEAN THIS. Don't be a tool.
Same way you would in a website. Store it server-side, have the app authenticate the user, send them a user-specific token, and then they can use that to ask your server to ask the API something for them.
Leaving aside solutions like React Query, I'll talk a bit more about React state management libraries and why I dislike selectors. I'll take a few popular state management libraries and contrast them to MobX (or MST).
So let's do a tiny component that shows Bears, Beets, and Battlestar Galacticas. It'll show the bears and beets, but not the BSGs, so we can measure if the component is rerendering when it shouldn't.
Caveat: I'm not an expert in all of these libraries, so if you know a better, more idiomatic way to do this, please let me know, and I'll adjust accordingly.