7 ms·
Every non-trivial (>10k lines) Cocoa/iOS/Android application I've ever seen or worked on has re-implemented at least some parts of React's data flow model. It's
by thurn 4y ago
Every non-trivial (>10k lines) Cocoa/iOS/Android application I've ever seen or worked on has re-implemented at least some parts of React's data flow model. It's surprising to me that the author glosses over handling lists, which is a huge challenge with this approach, and one that forces you to do some React-like stuff (UITableView cell recycling identifiers!) even if you don't want to.
However, there are definitely some problem domains that don't map very well to the React model. Real time games, for example, have very different requirements.
- chowells 4y agoEven real-time games are often best implemented as a pure function of state. This has a lot of advantages for keeping track of everything, especially in games with a network component. Of course, it doesn't mean the function from state to UI doesn't get to use mutable state - that's often critical for performance. What's important is logically separating the game state from the UI, such that any game state can be isolated, serialized, and de-serialized at will.
- crooked-v 4y agoI've had a very silly project in progress for a while along those lines to implement a Game Boy emulator entirely in Redux (state) and React (screen output, with pixels mapped to the appropriate bits). If I ever finish I imagine it will be incredibly slow, but it would allow for 'time traveling' the entire emulator state.
- elwell 4y agoI explored a little what it would mean to use pure functions to generate state for a game that has a little physics: https://github.com/celwell/wordsmith/blob/master/src/cljs/wordsmith/physics.cljs https://github.com/celwell/wordsmith/blob/master/src/cljs/wo...
- madeofpalk 4y agoon the other hand, AppKit/UIKit has UITableView/CollectionView view recycling just built into the framework, whereas everyone on web (including React libraries) is trying to reimplement it in userland
- manmal 4y agoLists are IMO the only area where imperative style has the upper hand - you can build truly endless lists because items are loaded lazily. UITableViewCell identifiers are cell _type_ ids, not cell ids btw, so they pose no overlap with React. If you need a very long list in React, you need to use a library with quite weird API.